Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At the time of writing, the following <code>setHeader</code> was copied from <a href="https://github.com/joyent/node/blob/master/lib/_http_outgoing.js" rel="nofollow noreferrer">the _http_outgoing page of node's core lib</a></p> <pre><code>var http = require('http'); http.OutgoingMessage.prototype.setHeader = function(name, value) { if (arguments.length &lt; 2) { throw new Error('`name` and `value` are required for setHeader().'); } if (this._header) { throw new Error('Can\'t set headers after they are sent.'); } // NO LOWER CASE var key = name//.toLowerCase(); this._headers = this._headers || {}; this._headerNames = this._headerNames || {}; this._headers[key] = value; this._headerNames[key] = name; // Since we're re-defining the method, we can't use this part anymore //if (automaticHeaders[key]) { // this._removedHeader[key] = false; //} }; </code></pre> <p>Commented out part for lowercase</p> <p>So.. if you get this problem. require http and override this method with the version you're currently using.</p> <p>It should then work properly. You could do a similar thing of overriding a method in ruby, but it won't be a quick and easy</p> <p>Then this will work:</p> <pre><code>require('request') request({url: 'http://myurl.com', headers: {UpperCaseWorks: 'Yay'}}) </code></pre> <hr> <p>EDIT: here's for the newer version of node</p> <pre><code>OutgoingMessage.prototype.setHeader = function setHeader(name, value) { if (this._header) { throw new errors.Error('ERR_HTTP_HEADERS_SENT', 'set'); } validateHeader(name, value); if (!this[outHeadersKey]) this[outHeadersKey] = {}; // no more lower case const key = name//.toLowerCase(); this[outHeadersKey][key] = [name, value]; switch (key.length) { case 10: if (key === 'connection') this._removedConnection = false; break; case 14: if (key === 'content-length') this._removedContLen = false; break; case 17: if (key === 'transfer-encoding') this._removedTE = false; break; } }; </code></pre> <p>Looks like it calls this local method, which'll need to be defined as well</p> <pre><code>function validateHeader(name, value) { let err; if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) { err = new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Header name', name); } else if (value === undefined) { err = new errors.TypeError('ERR_HTTP_INVALID_HEADER_VALUE', value, name); } else if (checkInvalidHeaderChar(value)) { debug('Header "%s" contains invalid characters', name); err = new errors.TypeError('ERR_INVALID_CHAR', 'header content', name); } if (err !== undefined) { Error.captureStackTrace(err, validateHeader); throw err; } } </code></pre> <p>And this</p> <pre><code>const { outHeadersKey } = require('internal/http'); </code></pre> <p>Anyway, check your version of node for what you are overriding</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload