When response content-length is 0, callback receives undefined as body parameter #414

Closed
cwilbur opened this Issue Jan 16, 2013 · 4 comments

Comments

Projects
None yet
2 participants
@cwilbur

cwilbur commented Jan 16, 2013

When request receives a response where the response body has a content-length of 0, request calls the callback and passes undefined as the body parameter to the callback. I believe that passing the empty string is more correct behavior.

@mikeal

This comment has been minimized.

Show comment Hide comment
@mikeal

mikeal Jan 16, 2013

Member

hrm.... let me think about this one a bit.

Member

mikeal commented Jan 16, 2013

hrm.... let me think about this one a bit.

@cwilbur

This comment has been minimized.

Show comment Hide comment
@cwilbur

cwilbur Jan 16, 2013

Upon half an hour's reflection, I think you can make a solid case either for undefined or the empty string. But it surprised me because I was expecting an empty string, and I wasn't sure it was intentional behavior. If you do decide that the current behavior is the correct one, a sentence in the docs to that effect wouldn't go amiss.

Thanks.

cwilbur commented Jan 16, 2013

Upon half an hour's reflection, I think you can make a solid case either for undefined or the empty string. But it surprised me because I was expecting an empty string, and I wasn't sure it was intentional behavior. If you do decide that the current behavior is the correct one, a sentence in the docs to that effect wouldn't go amiss.

Thanks.

@mikeal

This comment has been minimized.

Show comment Hide comment
@mikeal

mikeal Jan 16, 2013

Member

so, there is a change coming up for 3.0. streams2 changes some internal stream semantics we rely on. because of this change we're going to move to an API where "if you send a callback we'll buffer the body", where currently if you stream we'll call the callback just without the buffered body. at that point, having an empty string seems much more appropriate than undefined.

Member

mikeal commented Jan 16, 2013

so, there is a change coming up for 3.0. streams2 changes some internal stream semantics we rely on. because of this change we're going to move to an API where "if you send a callback we'll buffer the body", where currently if you stream we'll call the callback just without the buffered body. at that point, having an empty string seems much more appropriate than undefined.

ShaunK pushed a commit to ShaunK/node-soap that referenced this issue Dec 19, 2013

Shaun Kiernan
Fix for uncaught typeError (Issue 197)
The request library will return an undefined response object if a request response has a 0 length (see request/request#414). This causes node-soap to return an uncaught typeError exception, immediately killing the node process, since it doesn't check if the response object is undefined before trying to retrieve the headers from it.

ShaunK pushed a commit to ShaunK/node-soap that referenced this issue Dec 19, 2013

Shaun Kiernan
Fix for uncaught typeError (Issue 197)
The request library will return an undefined response object if a request response has a 0 length (see request/request#414). This causes node-soap to return an uncaught typeError exception, immediately killing the node process, since it doesn't check if the response object is undefined before trying to retrieve the headers from it.

ShaunK pushed a commit to ShaunK/node-soap that referenced this issue Dec 19, 2013

Shaun Kiernan
Fix for uncaught typeError (Issue 197)
The request library will return an undefined response object if a request response has a 0 length (see request/request#414). This causes node-soap to return an uncaught typeError exception, immediately killing the node process, since it doesn't check if the response object is undefined before trying to retrieve the headers from it.

@ShaunK ShaunK referenced this issue in vpulim/node-soap Dec 19, 2013

Closed

Fix for uncaught typeError (Issue 197) #198

ShaunK pushed a commit to ShaunK/node-soap that referenced this issue Jan 31, 2014

Shaun Kiernan
Fix for uncaught typeError (Issue 197)
The request library will return an undefined response object if a request response has a 0 length (see request/request#414). This causes node-soap to return an uncaught typeError exception, immediately killing the node process, since it doesn't check if the response object is undefined before trying to retrieve the headers from it.
@mikeal

This comment has been minimized.

Show comment Hide comment
@mikeal

mikeal Aug 28, 2014

Member

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.

Member

mikeal commented Aug 28, 2014

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.

@mikeal mikeal closed this Aug 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment