Git Product home page Git Product logo

Comments (7)

bortexz avatar bortexz commented on May 27, 2024

It seems a problem with my config, i'll investigate why.

from simple-get.

bortexz avatar bortexz commented on May 27, 2024

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.

feross avatar feross commented on May 27, 2024

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.

bortexz avatar bortexz commented on May 27, 2024

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.

feross avatar feross commented on May 27, 2024

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.

feross avatar feross commented on May 27, 2024

Are you sure that you're using browserify 11?

from simple-get.

bortexz avatar bortexz commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.