Skip to content
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

Could not parse data entirely #29

Open
kenn opened this issue Aug 2, 2013 · 3 comments
Open

Could not parse data entirely #29

kenn opened this issue Aug 2, 2013 · 3 comments

Comments

@kenn
Copy link

kenn commented Aug 2, 2013

Moved from igrigorik/em-http-request#240

em-http-request does not work for http://hashbang.ca/.

The following script:

require 'em-http-request'

EM.run do
  http = EM::HttpRequest.new('http://hashbang.ca/').head
  http.callback do
    puts "success"
    EM.stop
  end
  http.errback do
    puts "error: #{http.error}"
    EM.stop
  end
end

...returns this error.

error: Could not parse data entirely (389 != 645)

With telnet, I get the following response headers:

$ telnet hashbang.ca 80
Trying 178.79.155.139...
Connected to hashbang.ca.
Escape character is '^]'.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Server: nginx/1.4.1
Date: Tue, 23 Jul 2013 08:53:11 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.10-1ubuntu3.7
X-Pingback: http://hashbang.ca/xmlrpc.php
Expires: Tue, 23 Jul 2013 09:53:11 GMT
Cache-Control: max-age=3600
Strict-Transport-Security: max-age=31536000
Content-Security-Policy-Report-Only:
        default-src 'self';
        img-src *; style-src 'unsafe-inline' 'self';
        script-src platform.twitter.com rum-static.pingdom.net 'unsafe-inline' 'self';
        frame-src speakerdeck.com 'self';
        report-uri http://csp.hashbang.ca;

Connection closed by foreign host.

...where Content-Security-Policy-Report-Only looks odd. Could you give me any insights with the error?

FYI, browsers and net/http works fine with the site.

@tboyko
Copy link

tboyko commented Jan 29, 2016

@kenn Did you come to any conclusions on this problem?

@kenn
Copy link
Author

kenn commented Jan 30, 2016

Nope, but to be honest I haven't been following either http_parser or em-http-request lately.

@janko
Copy link

janko commented Jun 21, 2017

I have the same problem, for me this error is raised when there is some binary body in the same string as headers, because this fails:

parser = HTTP::Parser.new
parser.on_body { |chunk| }
parser << "HTTP/1.1 200 OK\r\nServer: gunicorn/19.7.0\r\nDate: Wed, 21 Jun 2017 06:26:07 GMT\r\nConnection: close\r\nTransfer-Encoding: chunked\r\nContent-Type: application/octet-stream\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\n\r\n\xD8\xC2kB\x82g\xC8Mz\x95"
HTTP::Parser::Error: Could not parse data entirely (242 != 250)                                                                                                                      

while this succeeds:

parser = HTTP::Parser.new
parser.on_body { |chunk| }
parser << "HTTP/1.1 200 OK\r\nServer: gunicorn/19.7.0\r\nDate: Wed, 21 Jun 2017 06:25:27 GMT\r\nConnection: close\r\nAccept-Ranges: bytes\r\nETag: range1000\r\nContent-Type: application/octet-stream\r\nContent-Length: 1000\r\nContent-Range: bytes 0-999/1000\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Credentials: true\r\n\r\nabcdefghijklmnopqrst"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants