Giter Club home page Giter Club logo

req-fast's People

Contributors

stelcheck avatar tjatse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

req-fast's Issues

_abort of undefined

While trying to download web pages, I ocasionally get this error.

URL = http://www.amulet.cz/doplnky/
C:\Users\sladg\Documents\Bohemian.studio\Crawler_4\node_modules\req-fast\lib\req_stream.js:257
this._data.request._aborted = true
^

TypeError: Cannot set property '_aborted' of undefined
at RequestStream.abort (C:\Users\sladg\Documents\Bohemian.studio\Crawler_4\node_modules\req-fast\lib\req_stream.js:257:31)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:86:13)
at ClientRequest.emit (events.js:188:7)
at Socket.emitRequestTimeout (_http_client.js:614:42)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
at Socket.emit (events.js:188:7)
at Socket._onTimeout (net.js:351:8)
at ontimeout (timers.js:386:14)`

Code responsible for this (req-fast/lib/req-stream.js line:250)

RequestStream.prototype.abort = function () {
  debug('FORCE ABORT!!!')
  try {
    this._data.request && this._data.request.abort()
  } catch (err) {
    debug.enabled && debug('-> failed due to %s', err.toString())
  }
  this._data.request._aborted = true // right here.
  this.emit('abort')
}

Fix:
I can understand that my solution is kind of ,,not-proper'', but it did the trick:

RequestStream.prototype.abort = function () {
  debug('FORCE ABORT!!!')
  try {
    this._data.request && this._data.request.abort()
  } catch (err) {
    debug.enabled && debug('-> failed due to %s', err.toString())
  }
  if (this._data === undefined) {
    this._data = ''
  }
  if (this._data.request === undefined) {
    this._data.request = ''
  }
  this._data.request._aborted = true
  this.emit('abort')
}

Cannot read property '_unzip' of undefined

Hi,

I just updated to the latest version, because I was getting an error like :

unexpected end of file     at Zlib._handle.onerror

which you just fixed, and now I am getting the following error using req-fast (in fact it's using read-art, which is using req-fast :)) :

/Users/jeremie/Documents/Workspace/AAA/Apps/aaa/node_modules/req-fast/lib/req_stream.js:117
          if (this._unzip) {
                  ^

TypeError: Cannot read property '_unzip' of undefined
    at shouldContinue (/Users/jeremie/Documents/Workspace/AAA/Apps/aaa/node_modules/req-fast/lib/req_stream.js:117:19)
    at RequestStream.onEnd (/Users/jeremie/Documents/Workspace/AAA/Apps/aaa/node_modules/req-fast/lib/req_stream.js:163:14)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at doNTCallback2 (node.js:452:9)
    at process._tickCallback (node.js:366:17)
Program node bin/www exited with code 1

req with POST doesn't work properly following doc

Hi,

I believe it's a mistake in either the doc / code:

A simple POST request like this doesn't work:
req({ url: queueUrl, headers: { 'Content-Type': 'text/xml' }, method: 'POST', data: asdfasdfasdfasdf}, ....

And the reason is due to "data" is not a valid property for options.
Seems like you're using "_data" for the options.
After i changed to use "_data", it works flawlessly.

No post data

When I send post data, the server receive nothing but if I send with method get, the data is there...

req({ url : 'http://www.com', method: 'POST', data: { nickname : nickname }, dataType: 'json' }, function(error, response) { console.log(response); });

Webpack causing issues

ERROR in ./~/tunnel2/lib/tunnel.js
Module not found: Error: Cannot resolve module 'net' in /web/sites/tripora/node_modules/tunnel2/lib
 @ ./~/tunnel2/lib/tunnel.js 3:10-24

ERROR in ./~/tunnel2/lib/tunnel.js
Module not found: Error: Cannot resolve module 'tls' in /web/sites/tripora/node_modules/tunnel2/lib
 @ ./~/tunnel2/lib/tunnel.js 4:10-24

ERROR in ./~/iconv-lite/encodings/tables/gb18030-ranges.json
Module parse failed: /web/sites/tripora/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:9)
    at Parser.pp$4.raise (/web/sites/tripora/node_modu```
ERROR in ./~/tunnel2/lib/tunnel.js
Module not found: Error: Cannot resolve module 'net' in /web/sites/example/node_modules/tunnel2/lib
 @ ./~/tunnel2/lib/tunnel.js 3:10-24

ERROR in ./~/tunnel2/lib/tunnel.js
Module not found: Error: Cannot resolve module 'tls' in /web/sites/example/node_modules/tunnel2/lib
 @ ./~/tunnel2/lib/tunnel.js 4:10-24

ERROR in ./~/iconv-lite/encodings/tables/gb18030-ranges.json
Module parse failed: /web/sites/example/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:9)
    at Parser.pp$4.raise (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp.semicolon (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:966:10)
    at Parser.pp$1.parseStatement (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:730:24)
    at Parser.pp$1.parseBlock (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:981:25)
    at Parser.pp$1.parseStatement (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:709:33)
    at Parser.pp$1.parseTopLevel (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:638:25)
    at Parser.parse (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:516:17)
    at Object.parse (/web/sites/example/node_modules/webpack/node_modules/acorn/dist/acorn.js:3098:39)
 @ ./~/iconv-lite/encodings/dbcs-data.js 99:37-76
```les/webpack/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp.semicolon (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:581:61)
    at Parser.pp$1.parseExpressionStatement (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:966:10)
    at Parser.pp$1.parseStatement (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:730:24)
    at Parser.pp$1.parseBlock (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:981:25)
    at Parser.pp$1.parseStatement (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:709:33)
    at Parser.pp$1.parseTopLevel (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:638:25)
    at Parser.parse (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:516:17)
    at Object.parse (/web/sites/tripora/node_modules/webpack/node_modules/acorn/dist/acorn.js:3098:39)
 @ ./~/iconv-lite/encodings/dbcs-data.js 99:37-76

set rate limitation

Hi,
how we can set rate limitation option a request? Because I've got Too Many Request error in my script I have to set this limitation.

It doesn't follow 301 redirect?

Hi, thanks for all of your works, many of your library is helpful.

I just tried req-fast but it's do not follow permanent redirect (301).
Is this expected behaviors?

var req = require('req-fast');
req({
    url: 'http://dentistvschef.wordpress.com/2013/01/16/japanese-spring-onionscallionleek-pancake-ala-dentist-chef/'
}, function(err, res){
    console.log(res.body);
});

Thanks

Fails for raw deflate encoded response

url: http://mp.weixin.qq.com/s?__biz=MjM5MzIyMDExOQ==&mid=400941252&idx=1&sn=0d98926515101df82e552720e93d6f6a&scene=2&srcid=11298yEW5zEhufnUxomV561q&from=timeline&isappinstalled=0#wechat_redirect

The server has "Content-Encoding: deflate" response header, and the response is raw deflate encoded content.

Browsers can parse the url correctly(Firefox&Chromium).

Checked the code, it's not an easy change to recover from inflate error(when error, we can try inflate using zlib.createInflateRaw) or maybe we can remove the deflate part in accept encoding request header(request library only sends "gzip").

toString() failed

This is error I got:

buffer.js:503
throw new Error('"toString()" failed');
^

Error: "toString()" failed
at Buffer.toString (buffer.js:503:11)
at RequestStream. (/home/adminvm/crawler/custom_modules/req-fast/lib/req.js:91:29)
at emitNone (events.js:86:13)
at RequestStream.emit (events.js:188:7)
at RequestStream.onEnd (/home/adminvm/crawler/custom_modules/req-fast/lib/req_stream.js:241:10)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

According to this thread: https://github.com/nodejs/node/issues/3175
This occurs when buffer exceed maximal length (268435440).

Code responsible:
/lib/req.js (line:91)

    if (typeof resp.body !== 'string') {
      resp.body = resp.body.toString()
    }

So I would recommend putting some function, which divides code to smaller parts and after .toString(), it puts them together.

I fixed it by simple:

if (resp.body.length > 265000000) {
    resp.body = ''
}

But it is suitable just in case you do not care about 1 page in thousands.

multipart/form-data upload?

Hi @Tjatse

I plan to ditch the request lib for all of my new projects, and i felt your req-fast could be the answer that i have been looking for (it's simple and to the point, and deserve more stars).

Today i have a problem uploading file to a site which uses REST API which use POST multipart/form-data as just like any HTML form do.

I know i can do it using request module, but i just wonder if it's possible with req-fast, since i don't want to require both request and req-fast as it's a module for similar task.

If you can write the code while not sacrifice any speed / lightness of req-fast, i think this should be at least included in req-fast as uploading file is a very common issue.

What do you think about this?

Thank you

post binary data encoding Problem

req.js

90 if (typeof resp.body !== 'string') {
91 resp.body = resp.body.toString()
92 }

90 if (typeof resp.body !== 'string' && "add resp.header.encoding" ) {
91 resp.body = resp.body.toString()
92 }

If response data encoding is binary, I can't take it as a buffer and write it to a file. ใ… ใ… 

Abort and error events both get called

I am not sure if this is normal or expected, but it seems that on error, both abort and error gets called. In my use case, I have manual aborts which I do wish to be able to keep track of (versus errors causing aborts).

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.