Files
kubernetes/pkg
Kubernetes Submit Queue 2bd077df6d Merge pull request #37477 from bruceauyeung/k8s-branch-fix-metrics-monitor-always-get-zero-value-http-code-in-ServeHTTP
Automatic merge from submit-queue

fix incorrect parameter pass to metrics.Monitor method call in ServeHTTP

**What this PR does / why we need it**:

before this PR:
1. `httpCode` is evaluated when defer statement executes, so all later assignments to `httpCode` is actually ineffectual. this obviously is not the design purpose.
2. `w.Header().Get("Content-Type")` is  evaluated when defer statement executes, so all later `w.Header().Set("Content-Type",xxx)` ( in `writeNegotiated` ) is ineffectual to `metrics.Monitor`, i think this also is not the design purpose.

after this PR:
1. `httpCode` and `w.Header().Get("Content-Type")` is evaluated when the defered anonymous function executes, so `metrics.Monitor` will get correct `httpCode` and `Content-Type` field value.
2. in `ServeHTTP` method there is not any modification to `req` parameter, so it's safe to defer its evaluation.

Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>
2016-12-20 02:24:05 -08:00
..
2016-12-17 00:07:24 +01:00
2016-12-15 14:20:26 -08:00
2016-12-15 09:18:48 -05:00
2016-12-12 13:30:07 -08:00
2016-12-19 16:05:48 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-14 12:39:48 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-14 12:39:49 -08:00
2016-12-12 13:30:07 -08:00
2016-12-19 23:13:14 +01:00
2016-12-14 12:39:48 -08:00
2016-12-12 13:30:07 -08:00
2016-12-14 12:39:48 -08:00
2016-12-19 16:22:41 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00
2016-12-12 13:30:07 -08:00