Vsevolod Strukchinsky
a1eb3f7801
Move setImmediate closer to sync event
> EventEmitter was made to be used as an abstraction around asynchronous events. Thus, when an event is emitted it will have happened on a different tick than when the event was set.
See https://github.com/joyent/node/issues/8470#issuecomment-58315886
10 years ago
Vsevolod Strukchinsky
16f93eaff1
Quick shims
10 years ago
Vsevolod Strukchinsky
04dbc4b728
Add Promise API
* Base logic moved into event-emitter and all APIs wrapped around it
* read-all-stream combined into one place - less code duplication
* Unzip stream now inherits all properties and function from response and returned instead of response
Closes #66
10 years ago
Vsevolod Strukchinsky
63d95b6316
Drop infinity-agent
Overall it is a bad practice to 'fix' internal modules within the other module.
I think graceful-fs (https://github.com/isaacs/node-graceful-fs#global-patching ) is good example, how to do this:
```js
var http = require('http');
var https = requrie('https');
var infinityAgent = require('infinity-agent');
infinityAgent.patch(http);
infinityAgent.patch(https);
```
This will enable global agent tuning in edge cases.
Closes #73 and closes #60
10 years ago
Vsevolod Strukchinsky
b9c33aa64e
Reselect agent on redirect from http to https
Closes #80
10 years ago
Sindre Sorhus
29e7e958fb
use the node builtin status codes
10 years ago
Vsevolod Strukchinsky
79f1390727
Emit response event only on final request
Closes #75
10 years ago
Connor Hindley
312c80d82c
do not parse json on a 204 response
10 years ago
Vsevolod Strukchinsky
d7a66baac7
Try pathname, if no path is specified
Closes #72
10 years ago
Vsevolod Strukchinsky
b7d4f8caca
Simplify get function and opts/arg juggling
Parse url at the top of got function and work with request object all the way down.
This reduces complexity and unnecessary delete calls in redirects.
10 years ago
Vsevolod Strukchinsky
3c06cca002
Move all code for options.body in one place
10 years ago
Vsevolod Strukchinsky
87d98e1f46
Add content-length header in POST
If:
- not already defined
- 'transfer-encoding' is not used
- body is not Stream
Closes #71
10 years ago
Sindre Sorhus
41d147baaf
minor code style improvements
10 years ago
Sindre Sorhus
550c63fcbe
use `is-redirect` module
10 years ago
Kirill Solovev
f94dcec259
Add accept: application/json header if json option is set
10 years ago
Kirill Solovev
e56f91373a
Access to body of non-200 responses in stream mode
10 years ago
Sindre Sorhus
6bde68ea79
💄
10 years ago
Sindre Sorhus
e3897a0bc0
TODO is a bad pattern
10 years ago
Vsevolod Strukchinsky
52490b2e88
Implement redirect event
Closes #58
10 years ago
Vsevolod Strukchinsky
2302a1e6e5
auto-redirect only on GET and HEAD methods
10 years ago
Vsevolod Strukchinsky
95add95542
fix redirects for host/port etc... in options
10 years ago
Vsevolod Strukchinsky
0797e46608
small fixes in validation
10 years ago
Vsevolod Strukchinsky
1e5993a799
fix query option on redirect
10 years ago
Vsevolod Strukchinsky
be47ce7168
fix query removal from opts
10 years ago
Vsevolod Strukchinsky
d7b1e51a5e
remove timeout and query from opts
10 years ago
Vsevolod Strukchinsky
6b015692aa
throw exception, if url is not string or object
10 years ago
Vsevolod Strukchinsky
53df1ca251
Add query option
10 years ago
Vsevolod Strukchinsky
47da1181a5
Accept http.request object as first argument
10 years ago
Vsevolod Strukchinsky
9f14fa61ea
tiny fix for consistency
10 years ago
Vsevolod Strukchinsky
d615b0bd2b
use returned value from pipe method as new response
10 years ago
Vsevolod Strukchinsky
68e0b26e79
remove unnecessary if branch
10 years ago
Vsevolod Strukchinsky
a0913bc13c
add body option validation
Throw nice error about body option,
instead of `first argument must be a string or Buffer`
from http.
10 years ago
Vsevolod Strukchinsky
472752af14
don't erase callback on helpers methods
https://github.com/sindresorhus/npm-name/issues/2
10 years ago
Vsevolod Strukchinsky
c06d741131
Use backported agents from Node core
10 years ago
Sindre Sorhus
ae73837301
don't mutate the user-supplied options object
10 years ago
Kevin Martensson
403fefa01a
Use camelCase names
10 years ago
Vsevolod Strukchinsky
82fa89c54d
Fix nested error on json parse
10 years ago
Vsevolod Strukchinsky
7da072b608
Parse non-200 responses when options.json is true
Closes #46
10 years ago
Vsevolod Strukchinsky
f8057d24fc
Add json option
10 years ago
Vsevolod Strukchinsky
26b1174bed
Use nested-error-stacks to provide more detailed errors
10 years ago
Vsevolod Strukchinsky
2b58c4499f
Unnecessary .call on callback
10 years ago
Kevin Martensson
929cb59857
Emit `response` event
10 years ago
Kevin Martensson
8873df99f7
Remove trailing space
10 years ago
Vsevolod Strukchinsky
ef8bdeb226
Improve error message on not 2xx code
Closes #38
10 years ago
Sindre Sorhus
e91768606c
extract the key lowercasing to a separate module
https://github.com/sindresorhus/lowercase-keys
10 years ago
Sindre Sorhus
d7737c7490
prevent duplicates of different casing in `opts.headers`
also make sure the user supplied object is never modified by us
10 years ago
Vsevolod Strukchinsky
93b6b7815f
🆙 read-all-stream to 1.0.0
10 years ago
Sindre Sorhus
c05add501c
minor tweaks
10 years ago
Kevin Martensson
a0985a62ec
Various tweaks
10 years ago
Sindre Sorhus
65b693bd80
minor tweaks
10 years ago