Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.0 #82

Merged
merged 7 commits into from
Jul 23, 2015
Merged

4.0.0 #82

merged 7 commits into from
Jul 23, 2015

Conversation

floatdrop
Copy link
Contributor

🐲 Here be dragons!

Promise API

As discussed in #66. pinkie-promise was taken as fallback for native Promise.

infinity-agent removed

Main reason to use infinity-agent was to fix internal maxSockets property on 0.10 version of NodeJS. But this approach is not quite configurable and not quite composable with custom agent, which could be necessary to fix #79

So infinity-agent should be dropped in favore to readme section with workaround:

require('http').globalAgent.maxSockets = Infinity;
require('https').globalAgent.maxSockets = Infinity;

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
* 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
unzip.setTimeout = res.setTimeout.bind(res);
unzip.statusCode = res.statusCode;
unzip.statusMessage = res.statusMessage;
unzip.socket = res.socket;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use objectAssign here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will copy internal fields and break unzip stream. Maybe turn it to a module?

@sindresorhus
Copy link
Owner

Yay! \o/

Gave it a quick shim and generally looks good. Will give it a proper review tomorrow.

// @julien-f @kevva @shinnn @arthurvr

> 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 nodejs/node-v0.x-archive#8470 (comment)
@floatdrop
Copy link
Contributor Author

@sindresorhus friendly ping :)

@sindresorhus
Copy link
Owner

Sorry about the delay. I'm traveling in Iceland at the moment. Will be back on Friday.

got.HTTPError = createErrorClass('HTTPError', function() {
this.message = 'Response code ' + this.statusCode + ' (' + http.STATUS_CODES[this.statusCode] + ')';
this.statusMessage = http.STATUS_CODES[this.statusCode];
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified:

Also the space after function

got.HTTPError = createErrorClass('HTTPError', function () {
  this.statusMessage = http.STATUS_CODES[this.statusCode];
  this.message = 'Response code ' + this.statusCode + ' (' + this.statusMessage + ')';
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sindresorhus
Copy link
Owner

Ok, found some time on the airport to review. Expect for some super minor nitpick this looks really good! I like how the code is a lot more readable now. Great work :)

Feel free to merge when the inline comments are resolved.

@floatdrop
Copy link
Contributor Author

I feel like some more time should be spent on Errors (because of #86, #72 and floatdrop/create-error-class#1), so new Errors will move to another PR.

@sindresorhus thanks for kind words ✨ I really miss 80-lines version of got, so tried to simplify things as much as I can.

floatdrop added a commit that referenced this pull request Jul 23, 2015
@floatdrop floatdrop merged commit e01aa05 into sindresorhus:master Jul 23, 2015
@floatdrop floatdrop deleted the 4.0.0 branch July 23, 2015 08:03
@arthurvr
Copy link

Super cool work, @floatdrop! ⭐

@sindresorhus
Copy link
Owner

@floatdrop Anything else we want to get into 4.0.0? Breaking changes would be nice to get in now so 5.0.0 can be far in the future.

@floatdrop
Copy link
Contributor Author

@sindresorhus nothing, except new Errors (#88).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proxy support
3 participants