flatiron/nock — Issue #41: Support for http.ClientRequest#setHeader, #getHeader, #removeHeader
Author: jherdman
Created: 2012-02-28 05:28:05+00:00
State: open

I'm developing a library to consume an HTTP API. I'm seeing the following error since adding an edge case that requires the usage of `http.ClientRequest#setHeader`:

```
TypeError: Object # has no method 'setHeader'
at [object Object].apiCall (/Users/james/Projects/urban-airship/lib/reques
t.js:112:9) at [object Object].get (/Users/james/Projects/urban-airship/lib/request.js
:129:15)
```

The lines in question:

```javascript
if (typeof data !== 'undefined') {
encodedData = JSON.stringify(data);

// THE NEXT TWO ARE THE OFFENDING LINES
req.setHeader('content-type', 'application/json');
req.setHeader('content-length', encodedData.length);

req.end(encodedData, 'utf8');
} else {
req.setHeader('content-length', 0);
req.end();
}
```

Where `req` is an instance of `http.ClientRequest`.