Comments (7)
It seems a problem with my config, i'll investigate why.
from simple-get.
Ok i've been stuck on that and discovered that if i use stream-http i'm getting the data as a Uint8Array, but if i use simple-get i'm getting it as a string, and then fails.
This code with simple-get fails:
get('http://localhost:8002/torrent', function (err, res) {
if (err) throw err
console.log(res.statusCode) // 200
var data = [] // List of Buffer objects
res.on('data', function (chunk) {
data.push(chunk) // Append Buffer object
})
res.on('end', function () {
data = Buffer.concat(data) // Make one large Buffer of it
console.log(data);
})
})
But this code with stream-http is working well
http.get('http://localhost:8002/torrent', function (res) {
var data = [] // List of Buffer objects
res.on('data', function (chunk) {
data.push(chunk) // Append Buffer object
})
res.on('end', function () {
data = Buffer.concat(data) // Make one large Buffer of it
})
})
I don't understand why this is happening. I've seen that simple-get uses the node.js http with browserify, so i'm thinking that probably my node.js version has something to do with that. I've tried with 0.12.7, 0.12.4 and 4.1 and none of them worked well.
Any advice would be apprecieted, i've been on this error for days and i cannot move forward :S
Thanks
from simple-get.
You wouldn't happen to be using the --no-browser-field
or --no-bf
flags to browserify? These turn off package.json
browser field resolution which would cause the unzip-response
package to be included in browser builds, despite the declaration here: https://github.com/feross/simple-get/blob/master/package.json#L11
More info here: https://gist.github.com/defunctzombie/4339901
Also, what browser are you running your examples in?
from simple-get.
Hi feross, thanks for your answer. No, i'm not using those flags, I use browserify with gulp and i'm using this config:
.pipe(browserify({
insertGlobals: true,
debug: true,
paths: ['client/'] // To make imports relative to this path, and save ourselfs from relative path hell
}))
I've tried latest version of Chrome and Firefox.
I'm now thinking on the paths: ['client/'] line, because i have a node.js backend and front end on the same project, and probably this is messing something up with browserify. The folder structure i'm using is the following:
/client
app/
components/
....
/server
/node_modules
package.json
gulpfile
If i understand well, I'm unzipping response when i shouldn't? That's why i'm seeing a string instead of a Buffer? That would explain a lot!
from simple-get.
If i understand well, I'm unzipping response when i shouldn't? That's why i'm seeing a string instead of a Buffer? That would explain a lot!
It was only a hunch. I still have no idea why this is happening. It would help if you could share a small snippet of code that causes this issue. Right now I can only guess what the problem is.
from simple-get.
Are you sure that you're using browserify 11?
from simple-get.
Finally figured it out! I was using gulp-browserify, which is deprecated, and probably using an older versions of browserify.
from simple-get.
Related Issues (20)
- support external piping HOT 3
- Promisify return value to allow async/await HOT 1
- How to figure out redirected URL?
- Do not follow Location headers for POSTs HOT 6
- timeout with HTTPS HOT 4
- Disable redirects
- Redirect bug
- Remove require('url') in favor of URL HOT 2
- basic auth support HOT 3
- Using simple-get in IONIC HOT 1
- Option to skip body decompression HOT 1
- JSON.parse error for 204 status code (no content)
- From http client to undici? HOT 1
- HTTP 500 response not returned with Node.js 14 and concat HOT 1
- Switch from querystring to URLSearchParams
- Switch to esm?
- SyntaxError: API error: Unexpected token < in JSON at position 0 HOT 1
- TypeScript types HOT 1
- Backport the recent security fix to 3.x HOT 8
- Node.js v19 Breaking Change HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-get.