1

I got this traceback when trying to upload a file using put_file (source code from example https://www.dropbox.com/developers/start/files#python). What does this error mean? And what is the suitable way to handle it?

Traceback (most recent call last):
  File "testDRBX.py", line 30, in <module>
    response = client.put_file('magnum-opus.txt', f)
  File "C:\Users\hicom\AppData\Roaming\Python\Python27\site-packages\dropbox\cli
ent.py", line 149, in put_file
    return RESTClient.PUT(url, file_obj, headers)
  File "C:\Users\hicom\AppData\Roaming\Python\Python27\site-packages\dropbox\res
t.py", line 146, in PUT
    return cls.request("PUT", url, body=body, headers=headers, raw_response=raw_
response)
  File "C:\Users\hicom\AppData\Roaming\Python\Python27\site-packages\dropbox\res
t.py", line 111, in request
    r = conn.getresponse()
  File "C:\Python27\lib\httplib.py", line 1027, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 407, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 371, in _read_status
    raise BadStatusLine(line)
httplib.BadStatusLine: ''
0

3 Answers 3

1

Problem is in USER-AGENT of HTTP header. It's 'OfficialDropboxPythonSDK/1.4' by default. I changed it in rest.py (row 55) to any other, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11' for example. Ploblem is solved.

Sign up to request clarification or add additional context in comments.

1 Comment

Why do you think the user agent is the problem? I tried Mozilla/5.0 and it doesn't work. I also tried Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 and it also doesn't work.
0

BadStatusLine means the connection was lost between your script and the Dropbox server, probably due to a timeout. You'll need to do the whole process faster, I think.

https://forums.dropbox.com/topic.php?id=34037#post-297553

Comments

0

The Dropbox API also results in BadStatusLine if you run requests too quickly and Dropbox's servers rate limit you.

My dev machine wasn't fast enough to trigger this, but an Amazon EC2 instance was able to trigger this condition when running 140 requests in rapid succession (list comprehension).

I don't think this is your case, but I wanted to note this for someone else who runs into this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.