The --timeout argument is not respected. #185

Closed
tylercrompton opened this Issue Dec 15, 2013 · 8 comments

Comments

Projects
None yet
2 participants

I've traced the code to find that the value supplied to HTTPie via the --timeout argument is sent to the requests library. However, No timeout ever occurs. The tests currently reflect this as well. Could somebody please look into this and verify that this is upstream?

Owner

jakubroztocil commented Dec 15, 2013

It looks like an upstream problem: It worked with requests 2.0.0, but doesn't work in 2.0.1.

https://travis-ci.org/jkbr/httpie/jobs/15478454#L51

@tylercrompton tylercrompton added a commit to tylercrompton/httpie that referenced this issue Dec 16, 2013

@tylercrompton tylercrompton fixes #185 changed from streaming to immediately downloading 85f3c47

@tylercrompton tylercrompton added a commit to tylercrompton/httpie that referenced this issue Dec 16, 2013

@tylercrompton tylercrompton fixes #185 changed from streaming to immediately downloading 5833ef7

I am using requests 2.1.0. I have looked into it further and it appears that when stream == True, timeout is not honored. This makes sense since a stream is not necessarily immediately used. How would it detect a timeout? requests works properly. The error is in HTTPie. See Pull Request #187.

Owner

jakubroztocil commented Dec 16, 2013

The timeout in Requests AFAIK is a time-to-connection timeout, so the streaming flag should not have impact on that.

You are correct on the first half of that statement. I'm actually looking at it right now and noticed that. The --stream option has nothing to do with this. Previous to the commit in Pull Request #187, the content is always streamed from the server. I changed it so that it would always download all of the content. A timeout will not be honored if streaming occurs. I've tested this with httpbin.org/delay/n. Try the following command.

$ python3 -c "import requests; response = requests.get('http://httpbin.org/delay/3', stream=True, timeout=1); print(response)"

Then try it without streaming.

$ python3 -c "import requests; response = requests.get('http://httpbin.org/delay/3', timeout=1); print(response)"

@tylercrompton tylercrompton added a commit to tylercrompton/httpie that referenced this issue Dec 16, 2013

@tylercrompton tylercrompton fixes #185 default timeout is None and streaming doesn't occur when t…
…here is a timeout set
5212019

Disregard that last commit. I'm actually going to delete that branch from my fork since this is not an HTTPie issue.

Should we make a note of the bug in the docs? Right now there's no reason for our --timeout option to even exist.

One solution we could do is to create a timer with some multithreading. I'll write it up if you'd merge such a change.

That's actually what the maintainers of Requests suggested. I'll need you to either merge or close #186 so that I can get started since I would have to modify what it modifies.

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