Skip to content

Commit

Permalink
Removed lowercasing of specified HTTP Headers and auto-inclusion of g…
Browse files Browse the repository at this point in the history
…ot User-Agent
  • Loading branch information
jacobmillsfl committed May 20, 2022
1 parent c25af09 commit d9f976c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"name": "got",
"name": "got-extra",
"version": "12.0.4",
"description": "Human-friendly and powerful HTTP request library for Node.js",
"description": "Extra Control Over Headers and Payloads in the got NodeJS Package",
"license": "MIT",
"repository": "sindresorhus/got",
"funding": "https://github.com/sindresorhus/got?sponsor=1",
"repository": "H0r53/got-extra",
"type": "module",
"exports": "./dist/source/index.js",
"engines": {
Expand Down
18 changes: 16 additions & 2 deletions source/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
} from 'node:https';
import type {InspectOptions} from 'node:util';
import is, {assert} from '@sindresorhus/is';
import lowercaseKeys from 'lowercase-keys';
//import lowercaseKeys from 'lowercase-keys';
import CacheableLookup from 'cacheable-lookup';
import http2wrapper, {ClientHttp2Session} from 'http2-wrapper';
import {isFormDataLike} from 'form-data-encoder';
Expand Down Expand Up @@ -716,9 +716,13 @@ const defaultInternals: Options['_internals'] = {
password: '',
http2: false,
allowGetBody: false,
headers: {
/*
Do not use default user-agent value
headers: {
'user-agent': 'got (https://github.com/sindresorhus/got)',
},
*/
headers: {},
methodRewriting: false,
dnsLookupIpVersion: undefined,
parseJson: JSON.parse,
Expand Down Expand Up @@ -1908,11 +1912,21 @@ export default class Options {
set headers(value: Headers) {
assert.plainObject(value);

/**
Respect the header keys as they are provided and do not lowercase
if (this._merging) {
Object.assign(this._internals.headers, lowercaseKeys(value));
} else {
this._internals.headers = lowercaseKeys(value);
}
*/
if (this._merging) {
Object.assign(this._internals.headers, value);
} else {
this._internals.headers = value;
}
}

/**
Expand Down

0 comments on commit d9f976c

Please sign in to comment.