-
Notifications
You must be signed in to change notification settings - Fork 801
requestheaders: new parameter inside debug.httpcalls.<BIDDER> to log request header details #1659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
4dc4076
fd02d4d
92d3b49
0217a04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,17 +308,19 @@ func getAssetByID(id int64, assets []nativeRequests.Asset) (nativeRequests.Asset | |
func makeExt(httpInfo *httpCallInfo) *openrtb_ext.ExtHttpCall { | ||
if httpInfo.err == nil { | ||
return &openrtb_ext.ExtHttpCall{ | ||
Uri: httpInfo.request.Uri, | ||
RequestBody: string(httpInfo.request.Body), | ||
ResponseBody: string(httpInfo.response.Body), | ||
Status: httpInfo.response.StatusCode, | ||
Uri: httpInfo.request.Uri, | ||
RequestBody: string(httpInfo.request.Body), | ||
ResponseBody: string(httpInfo.response.Body), | ||
Status: httpInfo.response.StatusCode, | ||
RequestHeaders: httpInfo.request.Headers, | ||
} | ||
} else if httpInfo.request == nil { | ||
return &openrtb_ext.ExtHttpCall{} | ||
} else { | ||
return &openrtb_ext.ExtHttpCall{ | ||
Uri: httpInfo.request.Uri, | ||
RequestBody: string(httpInfo.request.Body), | ||
Uri: httpInfo.request.Uri, | ||
RequestBody: string(httpInfo.request.Body), | ||
RequestHeaders: httpInfo.request.Headers, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Request Headers when there is error |
||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -886,6 +886,9 @@ func TestBadRequestLogging(t *testing.T) { | |
if ext.Status != 0 { | ||
t.Errorf("The Status code should be 0. Got %d", ext.Status) | ||
} | ||
if nil != ext.RequestHeaders || len(ext.RequestHeaders) > 0 { | ||
t.Errorf("The request headers should be empty. Got %s", ext.RequestHeaders) | ||
} | ||
ShriprasadM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
// TestBadResponseLogging makes sure that openrtb_ext works properly if we don't get a sensible HTTP response. | ||
|
@@ -894,6 +897,9 @@ func TestBadResponseLogging(t *testing.T) { | |
request: &adapters.RequestData{ | ||
Uri: "test.com", | ||
Body: []byte("request body"), | ||
Headers: http.Header{ | ||
"header-1": []string{"value-1"}, | ||
}, | ||
Comment on lines
+900
to
+902
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simulation of request headers set |
||
}, | ||
err: errors.New("Bad response"), | ||
} | ||
|
@@ -910,6 +916,7 @@ func TestBadResponseLogging(t *testing.T) { | |
if ext.Status != 0 { | ||
t.Errorf("The Status code should be 0. Got %d", ext.Status) | ||
} | ||
assert.Equal(t, info.request.Headers, http.Header(ext.RequestHeaders), "The request headers should be \"header-1:value-1\"") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify Request headers are logged when there is a bad response |
||
} | ||
|
||
// TestSuccessfulResponseLogging makes sure that openrtb_ext works properly if the HTTP request is successful. | ||
|
@@ -918,6 +925,9 @@ func TestSuccessfulResponseLogging(t *testing.T) { | |
request: &adapters.RequestData{ | ||
Uri: "test.com", | ||
Body: []byte("request body"), | ||
Headers: http.Header{ | ||
"header-1": []string{"value-1", "value-2"}, | ||
}, | ||
Comment on lines
+928
to
+930
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simulation of request headers set |
||
}, | ||
response: &adapters.ResponseData{ | ||
StatusCode: 200, | ||
|
@@ -937,6 +947,7 @@ func TestSuccessfulResponseLogging(t *testing.T) { | |
if ext.Status != info.response.StatusCode { | ||
t.Errorf("The Status code should be 0. Got %d", ext.Status) | ||
} | ||
assert.Equal(t, info.request.Headers, http.Header(ext.RequestHeaders), "The request headers should be \"%s\". Got %s", info.request.Headers, ext.RequestHeaders) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify Request headers are logged when there is a bad response |
||
} | ||
|
||
func TestMobileNativeTypes(t *testing.T) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ | |
{ | ||
"uri": "appnexusTest.com", | ||
"requestbody": "appnexusTestRequestBody", | ||
"requestheaders": { "header_1" : ["value_11", "value_12"], "header_2" : ["value_21"] }, | ||
"responsebody": "appnexusTestResponseBody", | ||
"status": 200 | ||
} | ||
|
@@ -95,7 +96,8 @@ | |
"uri": "audienceNetworkTest.com", | ||
"requestbody": "audienceNetworkTestRequestBody", | ||
"responsebody": "audienceNetworkTestResponseBody", | ||
"status": 200 | ||
"status": 200, | ||
"requestheaders": null | ||
ShriprasadM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
] | ||
} | ||
|
@@ -150,15 +152,17 @@ | |
"uri": "appnexusTest.com", | ||
"requestbody": "appnexusTestRequestBody", | ||
"responsebody": "appnexusTestResponseBody", | ||
"status": 200 | ||
"status": 200, | ||
"requestheaders": { "header_1" : ["value_11", "value_12"], "header_2" : ["value_21"] } | ||
} | ||
], | ||
"audienceNetwork": [ | ||
{ | ||
"uri": "audienceNetworkTest.com", | ||
"requestbody": "audienceNetworkTestRequestBody", | ||
"responsebody": "audienceNetworkTestResponseBody", | ||
"status": 200 | ||
"status": 200, | ||
"requestheaders": null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added new parameter to satisfy the unit test |
||
} | ||
] | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,10 +55,11 @@ type ExtBidderError struct { | |
|
||
// ExtHttpCall defines the contract for a bidresponse.ext.debug.httpcalls.{bidder}[i] | ||
type ExtHttpCall struct { | ||
Uri string `json:"uri"` | ||
RequestBody string `json:"requestbody"` | ||
ResponseBody string `json:"responsebody"` | ||
Status int `json:"status"` | ||
Uri string `json:"uri"` | ||
RequestBody string `json:"requestbody"` | ||
ResponseBody string `json:"responsebody"` | ||
Status int `json:"status"` | ||
RequestHeaders map[string][]string `json:"requestheaders"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new parameter RequestHeaders will contain the header key and multiple values associated with it. |
||
} | ||
|
||
// CookieStatus describes the allowed values for bidresponse.ext.usersync.{bidder}.status | ||
|
Uh oh!
There was an error while loading. Please reload this page.