title: Uploading a 0 bytes file to owncloud with python requests hangs
body: <p>I am trying to upload a 0 bytes file with requests to owncloud. I'd like to use a file-like object for that. Normally I'd do it like this:</p>
  
  <pre><code>file_obj = io.BytesIO(b'')
  response = requests.put('http://localhost/remote.php/webdav',
                                      auth=('xxx', 'xxx'),
                                      data=file_obj)
  </code></pre>
  
  <p>But it freezes. If I interrupt the process, I see where it hangs with the stack trace:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 376, in _make_request
      httplib_response = conn.getresponse(buffering=True)
  TypeError: getresponse() got an unexpected keyword argument 'buffering'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "/home/julian/cc/client/cc/storage/webdav.py", line 360, in &lt;module&gt;
      main()
    File "/home/julian/cc/client/cc/storage/webdav.py", line 351, in main
      data=file_obj)
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/api.py", line 120, in put
      return request('put', url, data=data, **kwargs)
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/api.py", line 53, in request
      return session.request(method=method, url=url, **kwargs)
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/sessions.py", line 468, in request
      resp = self.send(prep, **send_kwargs)
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/sessions.py", line 576, in send
      r = adapter.send(request, **kwargs)
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/adapters.py", line 376, in send
      timeout=timeout
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
      body=body, headers=headers)
    File "/home/julian/cc/client/.venv/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 378, in _make_request
      httplib_response = conn.getresponse()
    File "/usr/lib64/python3.5/http/client.py", line 1174, in getresponse
      response.begin()
    File "/usr/lib64/python3.5/http/client.py", line 282, in begin
      version, status, reason = self._read_status()
    File "/usr/lib64/python3.5/http/client.py", line 243, in _read_status
      line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
    File "/usr/lib64/python3.5/socket.py", line 575, in readinto
      return self._sock.recv_into(b)
  KeyboardInterrupt
  </code></pre>
  
  <p>Wireshark tells me requests sendet the following request, which seems to be fine, but never gets an answer:</p>
  
  <pre><code>PUT /remote.php/webdav/test.txt HTTP/1.1
  Host: localhost
  Connection: keep-alive
  Accept-Encoding: gzip, deflate
  Authorization: Basic ***********
  Transfer-Encoding: chunked
  User-Agent: python-requests/2.9.1
  Accept: */*
  Content-Length: 0
  </code></pre>
  
  <p>If I send an empty string, it works:</p>
  
  <pre><code>response = requests.put('http://localhost/remote.php/webdav/test.txt',
                                      auth=('xxx', 'xxx'),
                                      data='')
  </code></pre>
  
  <p>HTTP Stream:</p>
  
  <pre><code>PUT /remote.php/webdav/test.txt HTTP/1.1
  Host: localhost
  Content-Length: 0
  Accept-Encoding: gzip, deflate
  Connection: keep-alive
  User-Agent: python-requests/2.9.1
  Accept: */*
  Authorization: Basic ******
  
  
  
  HTTP/1.1 204 No Content
  Date: Thu, 24 Mar 2016 16:14:28 GMT
  Server: Apache/2.4.10 (Debian) PHP/5.6.19
  X-Powered-By: PHP/5.6.19
  Set-Cookie: xxx=xxx; path=/; HttpOnly
  Expires: Thu, 19 Nov 1981 08:52:00 GMT
  Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Pragma: no-cache
  Set-Cookie: oc_sessionPassphrase=xxxx; path=/; httponly
  Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *
  X-XSS-Protection: 1; mode=block
  X-Content-Type-Options: nosniff
  X-Frame-Options: Sameorigin
  X-Robots-Tag: none
  X-Download-Options: noopen
  X-Permitted-Cross-Domain-Policies: none
  Set-Cookie: xxx=xxx; path=/; HttpOnly
  OC-FileId: xxxxx
  Content-Length: 0
  ETag: "xxx"
  OC-ETag: "xxx"
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
  Content-Type: text/html; charset=UTF-8
  </code></pre>
  
  <p>This works as well:</p>
  
  <pre><code>def chunker(file_obj):
      buf = None
      while buf != b'':
          print('iter')
          buf = file_obj.read(16*1024)
          yield buf
  
  file_obj = io.BytesIO(b'')
  response = requests.put('http://localhost/remote.php/webdav/test.txt',
                                      auth=('xxx', 'xxx'),
                                      data=chunker(file_obj))
  </code></pre>
  
  <p>Any ideas why this is not working with file-like objects? I am using the latest version of requests (2.9.1) and Python 3.5.</p>