Skip to content
This repository has been archived by the owner on Feb 27, 2021. It is now read-only.

Commit

Permalink
set cookie only if it's needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki committed Feb 6, 2021
1 parent 548392e commit 7903d61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/socket-requester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ export class SocketRequester {
* @return {any}
*/
protected prepareHeaders(socket: any, options: any): any {
options.headers['Cookie'] = options.headers['Cookie'] || socket.request.headers.cookie;
options.headers['X-Requested-With'] = 'XMLHttpRequest';
options.headers['X-Forwarded-For'] = socket.request.headers['x-forwarded-for'] || socket.conn.remoteAddress;

if (socket.request.headers['user-agent']) {
options.headers['User-Agent'] = socket.request.headers['user-agent'];
}

let cookie = options.headers['Cookie'] || socket.request.headers.cookie;

if (cookie) {
options.headers['Cookie'] = cookie;
}

return options.headers;
}
}

0 comments on commit 7903d61

Please sign in to comment.