title: Uploading file using socket and Put with Python
body: <p>I am trying to upload a file to the server in a simple way and I am getting the following error:</p>
  
  <p>HTTP/1.1 411 Length Required</p>
  
  <p>Content-Type: text/html</p>
  
  <p>Date: Wed, 01 Jul 2015 03:05:33 GMT</p>
  
  <p>Connection: close</p>
  
  <p>Content-Length: 24</p>
  
  <p>Length Required</p>
  
  <p>I tried to insert length in different parts and looks like is not working, any suggestions?</p>
  
  <pre><code>import socket
  import httplib
  import os.path
  
  target_host = "192.168.1.1"
  target_port = 80
  total_size = os.path.getsize('/root/test.html')
  
  client = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  
  client.connect((target_host,target_port))
  
  client.send("PUT /root/test.html HTTP/1.1\r\nHost:192.168.1.1\r\n\r\n" )
  
  response = client.recv(4096)
  
  print response
  </code></pre>