NodeJS http.request fails when header is too large
<p>My code is as follows </p>

<pre><code>var http = require('http');
var host=...

var postData=({
         //some fun stuff
    })
    var postOptions ={
        host: host,
        path: '/api/dostuff',
        method: 'POST',
        headers:{
            AppID:"some stuff",
            Authorization: "OAuth token",
            "Content-Type":"application/json"
        },
    };

    var req = http.request(postOptions, function(res){
        var data = '';
        res.on('data', function (chunk) {
            data += chunk;
        });
        res.on('end', function () {
            //sanitize data stuff here
            console.log("DATA HERE: "+ data);

            return data;
        });
    });
    req.write(JSON.stringify(postData));
    req.end();
</code></pre>

<p>It's a basic HTTP post to a C# server. The important stuff is in the headers. I send the app ID (which is ~50 characters) and the OAuth token (which can be thousands of characters). Right now, the server isn't set up to do anything with the Authorization header. It doesn't even check if its there. </p>

<p>My problem is that when I populate the Authorization header (or any header) with a few random characters as a test, the post succeeds. When I tried it again with a full valid Authorization token (which, to reiterate, is very long) it fails. No matter which part of the header i fill, once it gets too full it returns an error. The error I receive is "Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details". I was somewhat certain this is a server issue, but when I tried running the exact same body and headers in Postman, I got a valid response.</p>

<p>Does anyone have any idea what is causing this?</p>