title: Python socket client Post parameters
body: <p>Fir let me clear <strong>I don't want to to use higher level APIs, I only want to use socket programming</strong></p>
  
  <p>I have wrote following program to connect to server using POST request.</p>
  
  <pre><code>import socket
  import binascii
  
  host = "localhost"
  port = 9000
  message = "POST /auth HTTP/1.1\r\n"
  parameters = "userName=Ganesh&amp;password=pass\r\n"
  contentLength = "Content-Length: " + str(len(parameters))
  contentType = "Content-Type: application/x-www-form-urlencoded\r\n"
  
  finalMessage = message + contentLength + contentType + "\r\n"
  finalMessage = finalMessage + parameters
  finalMessage = binascii.a2b_qp(finalMessage)
  
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.connect((host, port))
  s.sendall(finalMessage)
  
  print(s.recv(1024))
  </code></pre>
  
  <p>I checked online how POST request is created. </p>
  
  <p>Somehow Paramters are not getting passed to the server. Do I have to add or remove "\r\n" in between the request?</p>
  
  <p>Thanks in advance,
  Regards,
  Ganesh.</p>