I've been looking at request for the last couple of days and am now stuck with it. I'm looking for some pointers with the below issues (and also wanted to confirm that the features I'm trying to get working are not broken).
First, if I set headers like so:
I get nothing back (the response callback is never called). The web service I'm trying to talk to only accepts chunked connections, so I have to have it set (without "transfer-encoding: chunked" header the service returns an error "Monitor request must be done on a chunked encoding connection.") So, does request handle chunked connections? If so, are there any special considerations getting it to work?
I can get a "chunked" connection working against the API I'm working with using https.request, but the whole point I'm looking at request instead is that I'd like to keep the TCP connection open and multiplex multiple requests over it (it's the recommended way the web service in question should be accessed). https.request shuts down the socket right away, and so request's "forever()" might solve the problem.
The second question is about forever(). How do I enable it? I saw a suggestion in Google Groups to access forever like so:
var request = require('request').forever();
But when I do that, node exits with:
options.port = port
Thanks for any insights on this!
don't set the content-encoding header by hand, node core's http will automatically use chunked encoding if you don't set a content-length.
Yes, node's core http(s) seems to handle chunked encoding automatically, but it also closes the socket immediately after the request has been made which I'm trying to avoid – there's no way to send another request, say, couple of minutes later using the same socket.
Is there a way to enable chunked connections with your request module, and also employ the "forever" connections that are not automatically closed? In case of this application I'm doing POST over https.
Is this still an issue?
This is so old I'm closing, if it is actually still an issue just let me know and I'll re-open.
I have to say, this is an issue.. every time I attempt chunked transfer it;s a total fail. Either that or my attempt is wrong. However, I would expect there to be a series of examples and/or documentation for such functionality if it's supported.
Can you help out here?
The functionality I expect is asynchronous so I don't know if request is currently supporting this:
-I create a chunked transfer request and open the connection
-Once the connection is established I can send chunks of data from some readable stream.
-As some event happens (such as reading a row from a database), I want to send that chunk of data to the server in not only the same session, but the same pipe.
Thanks for any insight.
After hours of struggling and testing I came up with a solution. It works, that's all I care. I don't care if it looks terri-bad. I will post the solution to the examples area or something. Then I'll update this thread.