diff --git a/endpoints/cookie_sync_test.go b/endpoints/cookie_sync_test.go index 401c6796237..c8777c8b1a1 100644 --- a/endpoints/cookie_sync_test.go +++ b/endpoints/cookie_sync_test.go @@ -1756,7 +1756,7 @@ func TestCookieSyncHandleResponse(t *testing.T) { } else { bidderEval = []usersync.BidderEvaluation{} } - endpoint.handleResponse(writer, syncTypeFilter, cookie, privacyMacros, test.givenSyncersChosen, bidderEval, test.givenDebug) + endpoint.handleResponse(writer, syncTypeFilter, cookie, privacyMacros, test.givenSyncersChosen, bidderEval, test.givenDebug, false, 0) if assert.Equal(t, writer.Code, http.StatusOK, test.description+":http_status") { assert.Equal(t, writer.Header().Get("Content-Type"), "application/json; charset=utf-8", test.description+":http_header") diff --git a/endpoints/openrtb2/auction.go b/endpoints/openrtb2/auction.go index eb3f5c02ccb..7ebbfae76c3 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -2020,7 +2020,7 @@ func setDeviceImplicitly(httpReq *http.Request, r *openrtb_ext.RequestWrapper, i setIPImplicitly(httpReq, r, ipValidtor) setUAImplicitly(httpReq, r) setDoNotTrackImplicitly(httpReq, r) - + secCookieDeprecation(httpReq, r) } // setAuctionTypeImplicitly sets the auction type to 1 if it wasn't on the request, @@ -2352,6 +2352,33 @@ func setDoNotTrackImplicitly(httpReq *http.Request, r *openrtb_ext.RequestWrappe } } +func secCookieDeprecation(httpReq *http.Request, r *openrtb_ext.RequestWrapper) { + secCookieDeprecation := httpReq.Header.Get("Sec-Cookie-Deprecation") + if secCookieDeprecation == "" { + return + } + + if r.Device == nil { + r.Device = &openrtb2.Device{} + } + + updated := false + deviceExt := map[string]interface{}{} + if r.Device.Ext == nil { + updated = true + deviceExt["cdep"] = secCookieDeprecation + } else { + if err := json.Unmarshal(r.Device.Ext, &deviceExt); err == nil && deviceExt["cdep"] == nil { + updated = true + deviceExt["cdep"] = secCookieDeprecation + } + } + + if updated { + r.Device.Ext, _ = json.Marshal(deviceExt) + } +} + // Write(return) errors to the client, if any. Returns true if errors were found. func writeError(errs []error, w http.ResponseWriter, labels *metrics.Labels) bool { var rc bool = false