tomas / needle

Nimble, streamable HTTP client for Node.js. With proxy, iconv, cookie, deflate & multipart support.
https://www.npmjs.com/package/needle
MIT License
1.63k stars 236 forks source link

Simple request URI modification logic #311

Closed awiejacha closed 4 years ago

awiejacha commented 4 years ago

This small code gives opportunity to 'intercept' and modify request URI on-the-fly. When application is used to crawl/visit over resources, making request in the automated way, in some cases it is needed to modify uri/querystring, basing on some rules - e.g. we know that for specific location additional querystring or chunk of path needs to be appended/removed.

Additionally, fixed a bug with resp.cookies being undefined if follow_set_cookies is enabled and previous response cookies not present and set-cookie headers is not present.

tomas commented 4 years ago

Looks good but I'd try to use a more descriptive method for the option. Something like uri_modifier perhaps?

awiejacha commented 4 years ago

Sure - just 5 chars more and much more description.

tomas commented 4 years ago

OK would you update your PR?

awiejacha commented 4 years ago

Updated. Thanks for keeping eye on this!