New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get empty body from a response with "Connection:close" header #604

Closed
mesterum opened this Issue Mar 31, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@mesterum

mesterum commented Mar 31, 2014

http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 says " the transfer-length of that body is determined by [...] 5.By the server closing the connection."

In module vibe.http.client, property InputStream bodyReader() of HTTPClientResponse class limits to 0 the InputStream if I don't get from the server, a response with a "Content-Length" or at least a "Transfer-Encoding" header, though I get a "Connection:close" header.
Module vibe.http.proxy behave accordingly.

@s-ludwig s-ludwig added the bug label May 16, 2014

@sinkuu

This comment has been minimized.

Show comment
Hide comment
@sinkuu

sinkuu Jan 8, 2016

Contributor

I'm trying to communicate with the server that responds like this, and got empty body too.

HTTP/1.0 200 OK
Content-Type: text/plain

hello

my workaound:

diff --git a/source/vibe/http/client.d b/source/vibe/http/client.d
index 5bd334a..47c64c1 100644
--- a/source/vibe/http/client.d
+++ b/source/vibe/http/client.d
@@ -846,8 +846,12 @@ final class HTTPClientResponse : HTTPResponse {
            m_limitedInputStream = FreeListRef!LimitedInputStream(m_client.m_stream, to!ulong(*pcl));
            m_bodyReader = m_limitedInputStream;
        } else {
-           m_limitedInputStream = FreeListRef!LimitedInputStream(m_client.m_stream, 0);
-           m_bodyReader = m_limitedInputStream;
+           if (m_client.m_stream.empty){
+               m_limitedInputStream = FreeListRef!LimitedInputStream(m_client.m_stream, 0);
+               m_bodyReader = m_limitedInputStream;
+           } else {
+               m_bodyReader = m_client.m_stream;
+           }
        }

        if( auto pce = "Content-Encoding" in this.headers ){
Contributor

sinkuu commented Jan 8, 2016

I'm trying to communicate with the server that responds like this, and got empty body too.

HTTP/1.0 200 OK
Content-Type: text/plain

hello

my workaound:

diff --git a/source/vibe/http/client.d b/source/vibe/http/client.d
index 5bd334a..47c64c1 100644
--- a/source/vibe/http/client.d
+++ b/source/vibe/http/client.d
@@ -846,8 +846,12 @@ final class HTTPClientResponse : HTTPResponse {
            m_limitedInputStream = FreeListRef!LimitedInputStream(m_client.m_stream, to!ulong(*pcl));
            m_bodyReader = m_limitedInputStream;
        } else {
-           m_limitedInputStream = FreeListRef!LimitedInputStream(m_client.m_stream, 0);
-           m_bodyReader = m_limitedInputStream;
+           if (m_client.m_stream.empty){
+               m_limitedInputStream = FreeListRef!LimitedInputStream(m_client.m_stream, 0);
+               m_bodyReader = m_limitedInputStream;
+           } else {
+               m_bodyReader = m_client.m_stream;
+           }
        }

        if( auto pce = "Content-Encoding" in this.headers ){

@s-ludwig s-ludwig closed this in 8e0e3f0 Jan 10, 2016

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