3 ms·
I think roughly 40% of the remaining code implements the last 20% of the features, and the other 50% is just random bloat. Request has a lot of extra code to d
by azylman 14y ago
I think roughly 40% of the remaining code implements the last 20% of the features, and the other 50% is just random bloat.
Request has a lot of extra code to deal with the global state. It's written as one giant class that sets all of its properties on itself (e.g. this.method = options.method, etc., etc., followed by "http.request this"). Further, when it handles HTTP redirects, rather than instantiate a new instance of itself or something it just calls its init method a second time and has to make sure that it resets all of its properties to their default state (e.g. this.method = 'GET'). This is where most of the bugs come in, as well as most of the bloat.
In contrast, our's is a method that calls itself again with new options based on the context when it needs to handle HTTP redirects so we don't need to worry about that sort of stuff.