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

bug: tuple assignment from underpopulated list #15

Open
cfcs opened this issue Mar 13, 2016 · 4 comments
Open

bug: tuple assignment from underpopulated list #15

cfcs opened this issue Mar 13, 2016 · 4 comments

Comments

@cfcs
Copy link

cfcs commented Mar 13, 2016

<type 'exceptions.ValueError'>: need more than 1 value to unpack
  File "/usr/lib64/python2.7/SocketServer.py", line 599, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/user/burst/burst/proxy.py", line 40, in __init__
    SocketServer.StreamRequestHandler.__init__(self, request, client_address, server)
  File "/usr/lib64/python2.7/SocketServer.py", line 655, in __init__
    self.handle()
  File "/home/user/burst/burst/proxy.py", line 230, in handle
    if not self.handle_one_request():
  File "/home/user/burst/burst/proxy.py", line 297, in handle_one_request
    if not self._do_connection():
  File "/home/user/burst/burst/proxy.py", line 141, in _do_connection
    self.r(conn=self.conn)
  File "/home/user/burst/burst/http.py", line 250, in __call__
    self._read_response(sock, chunk_func)
  File "/home/user/burst/burst/http.py", line 253, in _read_response
    self.response = Response(sock.makefile('rb', 0), self, chunk_func=chunk_func)
  File "/home/user/burst/burst/http.py", line 447, in __init__
    self.raw_content = read_content(fd, parse_headers(self.raw_headers), self.status,
  File "/home/user/burst/burst/http.py", line 941, in parse_headers
    t, v = [q.strip() for q in l.split(":", 1)]
@tweksteen
Copy link
Owner

It seems like one of the response header did not have a colon. Would you have a copy of the request or response that triggered that?

It may be worth patching the code to still add the header (with an empty value) or simply skip.

@cfcs
Copy link
Author

cfcs commented Mar 14, 2016

Sorry, yes I ended up using curl to work around it.
The backend was a HTTP/1.0 CGI service that would dump errors to stdout before writing the newlines, so it would end up with output similar to the stuff below (I don't have a copy of the output on hand):

500 HTTP/1.0
Cookie: session=abcdef1234124
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in root:x:0:0:root:
[.. cfcs cut ..]

I concur that it would be worth handling instances like this in a slightly more graceful way to enable parsing of the output.

@tweksteen
Copy link
Owner

Well that case is quite tricky, I don't rely on much to parse the response but the new line character between headers and body is a must have. If I apply what I mentioned, that would creates weird headers (key="This software comes with NO WARRANTY", value="see the file PUBLIC for details.") and likely to block if there is no new line character at all... but I guess that would work in your case (at least not die, and give you access to the response object).

Could you add a try/except around the faulty line and send a pull request?

Also, interesting response you have there :)

@cfcs
Copy link
Author

cfcs commented Mar 15, 2016

Yes, well, headers aren't supposed to have spaces, so one way to semi-reliably detect this kind of behavior would be to attempt splitting by :, and checking for spaces in the left-hand part of the line to detect that something went wrong.

Yes, I'll fix a PR.

And yes! :-)

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

2 participants