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
browserify support #455
Comments
we need to get a pull request in to the mime module. |
Getting there: https://github.com/dominictarr/node-mime |
bumping this with an update: https://twitter.com/maxogden/status/413057941185372160 tl;dr @mikeal said he's hoping to work on this over xmas break |
Did santa deliver on this one? Want to use it for NeoCities API client for node http://neocities.org/api |
http://npmjs.org/xhr is the best bet right now, it got some love recently. |
Some folks forked node-mime and took on browser-compatibility. It should be a trivial drop-in replacement: https://github.com/expressjs/mime-types |
I'll +1 a PR that swaps the mime library fro one that is browserifyable. |
Hello. So the issue referenced right above this comment should fix that mime problem and get request ready for being "browserified" without error. However, I ran into one additional issue while using request with browserify. I am pretty sure you guys have a better understanding as to how to proceed with it, but this is the temporary hack I added: diff --git a/request.js b/request.js
index caa1394..001a380 100644
--- a/request.js
+++ b/request.js
@@ -716,7 +716,7 @@ Request.prototype.onResponse = function (response) {
debug('response end', self.uri.href, response.statusCode, response.headers)
});
- if (response.connection.listeners('error').indexOf(self._parserErrorHandler) === -1) {
+ if (response.connection && response.connection.listeners('error').indexOf(self._parserErrorHandler) === -1) {
response.connection.once('error', self._parserErrorHandler)
}
if (self._aborted) {
@@ -725,7 +725,7 @@ Request.prototype.onResponse = function (response) {
return
}
if (self._paused) response.pause()
- else response.resume()
+ else response.resume && response.resume() As you might understand, (also if my temporary hack is the only way to go, and you feel like it's alright, I'll open another PR for it) |
why doesn't response have a resume() method? i would think that the stream shim would provide that? |
oh, also, can you put a comment on each of these lines saying that it is for browserify, cause i'm going to forget this entirely in the next refactor :) |
Sorry if my question was not so obvious, but does that mean you want me to create a PR with those lines? (including comments of course) My comment was also meant as a question (as you mention yourself) as to why this does not work. :) But PR it is, if you want... :) |
I'm interested in why this is required but that doesn't mean I won't accept a workaround right now that gets us to a browserifyable request :) |
I like (and agree with) the pragmatism :) Pull request sent. |
FYI current |
This was apparently introduced in 2.46 or something, when form-data started to be a dependency instead of an optional dependency. PR to form-data, maybe? |
Ping @mikeal re bounty on this issue See form-data/form-data#87, looks like it just needs some cleanup. |
Just tested replacing the mime library in form-data, and that fixes the issue. Sent a cleaned up PR just like the above mentioned. |
Upgrade form-data, add back browserify compability. Fixes #455.
Can we publish a new version, by the way? |
Also, can someone list the last known version to work with browserify? Until a new version is published, it would be good for folks who find this to be able to know what works. |
It looks like |
|
request/request#455 (comment) Also, the browser-request library doesn't include the .on function used here https://github.com/spark/sparkjs/blob/master/lib/spark.js#L667, so trying to do any event subscribing in the browser just results in 'undefined is not a function' in a minified file, which isn't super helpful.
…ary. Note this depends on request's built in support for being browser friendly: request/request#455.
While working on tilgovi/chromify last month I ran into an issue where the mime types file couldn't be read by request (because it wasn't included). At the time I hacked around it hard by bundling the mime types file through emscripten and a readFileSync that read from that.
With the 'browser' attribute of either request or the mime types module I bet we can preload the data so that it just works.
I'll look into it and come back with a PR over the weekend.
The text was updated successfully, but these errors were encountered: