You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hm, seems like the request object needs the Content-Length in order be constructed. Since getting the value for that is async it can't be returned right away. Got an idea for a patch?
We can create request object before async call and return it and populate it later. But I was thinking that it's might be confusing to return httpRequest from FormData, since people might expect it to be same object.
Maybe we'll be better off just translating events.
@visionmedia How are you going track the progress on httpRequest?
unfortunate we can't initialize a node request to return (that I know of at least), emitting an event would be pretty weird, two callbacks is weird. I just wrote submit() with the progress stuff built in but im not sure what would be best in here. hmm yeah aside from an event or second callback I'm not sure
and later using that to do the actual progress reporting. Maybe if we make that stuff into a little module and just do trackProgress(req).on('progress', re-emit crap here) we could add it to form-data :s haha, but no point turning it into another request library
if(params.request){request=params.request;}else{// https if specified, fallback to http in any other caseif(params.protocol=='https:'){// override default portif(!params.port)options.port=443;request=https.request;}else{request=http.request;}}request=request(options);
then you can have your own augmented request instantiation function.
Oh, looks like we still can add content-length later:
"The header is still mutable using the setHeader(name, value), getHeader(name), removeHeader(name) API. The actual header will be sent along with the first data chunk or when closing the connection."
But, again, don't you think it will be confusing to return httpRequest from FormData.submit?
Activity
felixge commentedon Aug 20, 2013
Hm, seems like the request object needs the
Content-Lengthin order be constructed. Since getting the value for that is async it can't be returned right away. Got an idea for a patch?alexindigo commentedon Aug 20, 2013
We can create request object before async call and return it and populate it later. But I was thinking that it's might be confusing to return httpRequest from FormData, since people might expect it to be same object.
Maybe we'll be better off just translating events.
@visionmedia How are you going track the progress on httpRequest?
tj commentedon Aug 20, 2013
unfortunate we can't initialize a node request to return (that I know of at least), emitting an event would be pretty weird, two callbacks is weird. I just wrote submit() with the progress stuff built in but im not sure what would be best in here. hmm yeah aside from an event or second callback I'm not sure
tj commentedon Aug 20, 2013
@alexindigo I'm just proxying the .write() to the request with this hack:
and later using that to do the actual progress reporting. Maybe if we make that stuff into a little module and just do
trackProgress(req).on('progress', re-emit crap here)we could add it to form-data :s haha, but no point turning it into another request libraryalexindigo commentedon Aug 20, 2013
How about?
then you can have your own augmented request instantiation function.
alexindigo commentedon Aug 20, 2013
Oh, looks like we still can add content-length later:
"The header is still mutable using the setHeader(name, value), getHeader(name), removeHeader(name) API. The actual header will be sent along with the first data chunk or when closing the connection."
But, again, don't you think it will be confusing to return httpRequest from FormData.submit?
tj commentedon Aug 21, 2013
I think returning it is the most sensible thing personally, especially since it wont break anyone's apps since it's not returning
thisfor chainingform-data#47 return request from .submit()
alexindigo commentedon Aug 21, 2013
@visionmedia @felixge Something like that.
form-data#47 Updated readme.
Merge pull request #48 from alexindigo/master