Comments (12)
Yes, that's the expected behaviour. Were you expecting something different?
The option is parse: false
by the way!
from needle.
Sorry, I typo'd the issue here. 😀
The service I'm interacting with returns files, which occassionally can be JSON files, which should be saved to disk. Doing a simple needle.get
and piping to fs.createWriteStream
was successful until I encountered this case.
The only documentation around piping in this module shows a web request being written to disk via the same manner. Therefore it "feels" like a bug when this is violated by the stream being knocked into object mode by the JSON or XML parsers.
from needle.
I'm wondering, what makes a JSON file different from a JSON string? As far as I can see, to Needle it's basically a JSON object that should be parsed, given that the response's Content-Type says so.
I think this is more an edge case than an actual bug. :)
from needle.
@terinjokes I'm closing this one for the time being. Feel free to reopen if you think there's a better way of handling this.
from needle.
var stream = needle.request('post', url, {}, {
decode: false,
parse: false
});
stream.pipe(response);
stream.on('end', function () {
// Never be fired without `parse: false`
});
@tomas, Please pay attention to this point in the documentation!
from needle.
@monolithed Is that so? What URL are you testing with?
from needle.
@tomas, public url like https://e.mail.ru
from needle.
@monolithed Can you share a full code example? I don't know where the response
object you show comes from.
from needle.
app.use(express.cookieParser());
app.use(function (request, response, next) {
get_cookies(function () {
request.cookies = result.cookies;
next();
});
});
app.use('/api', function (request, response, next) {
var url = 'https://e.mail.ru/api' + request.url;
var stream = needle.request(request.method, url, request.body, {
cookies: request.cookies,
parse : false
});
stream.pipe(response);
});
Could not close connection without parse: false
. It seems very strange...
from needle.
Ok, gonna test it now. Which needle version are you running?
from needle.
I just tested and running the latest Needle (from git, not npm) I do get the 'end' event emitted. This might have to do with a few recent changes related to the Connection header.
I haven't pushed a new version to NPM because I need to update the documentation first. However you can safely run the latest version of git since all new major changes have been thoroughly covered with tests.
from needle.
0.11.0, thanks
from needle.
Related Issues (20)
- Incorrect parsing of complex JS nested objects in POST request HOT 5
- Mangled file content when multipart-POSTing a file with a "text/*" content type HOT 2
- Very infrequent TypeError: iconv.encodingExists is not a function
- Tunnelling doesn't work in v3.1.0 HOT 12
- Proposal: Supporting User-Defined "Follow If" Conditions
- Piping needle request to Express response won't set the correct headers
- Multiple Files Upload Renames Input Field
- Uncaught asynchronous error
- Remote end closed socket abruptly errors HOT 2
- a ':' in nonce breaks digest authentication HOT 1
- Digest MD5 not working with Geovision IP Camera
- Uncaught ECONNRESET exception
- needle.get cannot guaranty getting the http stream HOT 2
- FEATURE: Retry HOT 1
- follow_set_cookies -> not working!!!
- Bug in 3.3.0: accidental creation of `global.signal`, gets caught in strict UTs
- README recommends mikeal's request HOT 3
- Multipart uploads strips date values in the request body HOT 2
- Doesn't work in Cloudflare Workers HOT 1
- Sorry, I was about to post this issue to a different repo, don't even know how it happened that I posted it here
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 needle.