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

send host header with the GET request #2

Merged
merged 2 commits into from
May 14, 2016
Merged

Conversation

lrusak
Copy link
Contributor

@lrusak lrusak commented May 12, 2016

Changes in golang 1.6 don't allow http requests with a null host header.

This causes

HTTP/1.1 400 Bad Request
Content-Type: text/plain
Connection: close

400 Bad Request: missing required Host header
Traceback (most recent call last):
  File "./dockermon.py", line 146, in <module>
    watch(callback, args.socket_url)
  File "./dockermon.py", line 82, in watch
    raise DockermonError('bad HTTP status: %s %s' % (status, reason))
__main__.DockermonError: bad HTTP status: 400 Bad Request

To fix this we just need to include some host header. The fix was taken from here

see these links for more info.
golang/go#15276
golang/go#13624

@@ -74,7 +74,7 @@ def watch(callback, url=default_sock_url):
sock = connect(url)

with closing(sock):
sock.sendall(b'GET /events HTTP/1.1\n\n')
sock.sendall(b'GET /events HTTP/1.1\nHost: foo\n\n')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use the real host name if it's a TCP connection and localhost if it's IPC.

@lrusak
Copy link
Contributor Author

lrusak commented May 13, 2016

I've updated it with the requested changes.

@tebeka tebeka merged commit e3dbeab into CyberInt:master May 14, 2016
@tebeka
Copy link
Contributor

tebeka commented May 14, 2016

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants