Skip to content
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

Prebid Server Bid Adapter : Support for custom headers for XHR call #11780

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/ceeIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const ceeIdSubmodule = {
* performs action to obtain id and return a value
* @function
* @returns {(IdResponse|undefined)}
*/
*/
getId(config) {
const { params = {} } = config;
const { tokenName, value } = params
Expand Down
4 changes: 3 additions & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export const processPBSRequest = hook('sync', function (s2sBidRequest, bidReques
const requestJson = request && JSON.stringify(request);
logInfo('BidRequest: ' + requestJson);
const endpointUrl = getMatchingConsentUrl(s2sBidRequest.s2sConfig.endpoint, gdprConsent);
const customHeaders = deepAccess(s2sBidRequest, 's2sConfig.customHeaders', {});
if (request && requestJson && endpointUrl) {
const networkDone = s2sBidRequest.metrics.startTiming('net');
ajax(
Expand Down Expand Up @@ -584,7 +585,8 @@ export const processPBSRequest = hook('sync', function (s2sBidRequest, bidReques
{
contentType: 'text/plain',
withCredentials: true,
browsingTopics: isActivityAllowed(ACTIVITY_TRANSMIT_UFPD, s2sActivityParams(s2sBidRequest.s2sConfig))
browsingTopics: isActivityAllowed(ACTIVITY_TRANSMIT_UFPD, s2sActivityParams(s2sBidRequest.s2sConfig)),
customHeaders
}
);
} else {
Expand Down
14 changes: 14 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,20 @@ describe('S2S Adapter', function () {
})
})
})

it('should set customHeaders correctly when publisher has provided it', () => {
let configWithCustomHeaders = utils.deepClone(CONFIG);
configWithCustomHeaders.customHeaders = { customHeader1: 'customHeader1Value' };
config.setConfig({ s2sConfig: configWithCustomHeaders });

let reqWithNewConfig = utils.deepClone(REQUEST);
reqWithNewConfig.s2sConfig = configWithCustomHeaders;

adapter.callBids(reqWithNewConfig, BID_REQUESTS, addBidResponse, done, ajax);
const reqHeaders = server.requests[0].requestHeaders
expect(reqHeaders.customHeader1).to.exist;
expect(reqHeaders.customHeader1).to.equal('customHeader1Value');
});

it('should block request if config did not define p1Consent URL in endpoint object config', function () {
let badConfig = utils.deepClone(CONFIG);
Expand Down