title: Post data send in python using socket
body: <p>I write a code who has to click a button on website, by sending a POST request. I use sockets to this. Here is my code:</p>
  
  <pre><code>import sys
  import socket
  import time
  import socks
  
  red = "\033[1;31m"
  green = "\033[1;32m"
  yellow = "\033[1;33m"
  blue = "\033[1;34m"
  defcol = "\033[0m"
  
  
  
  
  s = socks.socksocket()
  s.set_proxy(socks.SOCKS5, "209.33.198.133", 9999)
  ipaddr = socket.gethostbyname('mclista.pl')
  #ipaddr = 'mclista.pl'
  s.connect(("149.202.218.96", 80))
  
  
  header = ("""
  POST /json/daj_diax/ HTTP/1.1
  Host: www.mclista.pl
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0
  Accept: application/json, text/javascript, */*; q=0.01
  Accept-Language: pl,en-US;q=0.7,en;q=0.3
  Accept-Encoding: gzip, deflate
  Referer: https://www.google.com
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  X-Requested-With: XMLHttpRequest
  Content-Length: 68
  Connection: keep-alive
  Cookie: _ga=GA1.2.942145996.1539109230; _gid=GA1.2.1111512675.1541185659; csrf_mclista=65d10295bd238ea3c81f19b3e02d073c; ci_session=a%3A5%3A%7Bs%3A10%3A%22session_id%22%3Bs%3A32%3A%22d1e9deec40aa713329f98ddd11ce042f%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A10%3A%225.184.63.6%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A78%3A%22Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%3B+rv%3A63.0%29+Gecko%2F20100101+Firefox%2F63.0%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1541242717%3Bs%3A9%3A%22user_data%22%3Bs%3A0%3A%22%22%3B%7D913ae0005d8fb07d1b6dc486b7fc9297; _gat=1
  """)
  
  print(yellow + header)
  request = header
  s.sendall(request.encode('utf-8'))
  response = s.recv(4096)
  time.sleep(2)
  print('\n\n\n\n\n\n\n' + blue + str(response) + '\n')
  s.close()
  </code></pre>
  
  <p>My question is, why on send i getting it response: </p>
  
  <pre><code>HTTP/1.1 400 Bad Request
  Date: Sat, 03 Nov 2018 11:20:02 GMT
  Server: Apache
  Content-Length: 226
  Connection: close
  Content-Type: text/html; charset=iso-8859-1
  
  &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  &lt;html&gt;&lt;head&gt;
  &lt;title&gt;400 Bad Request&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;h1&gt;Bad Request&lt;/h1&gt;
  &lt;p&gt;Your browser sent a request that this server could not understand.&lt;br /&gt;
  &lt;/p&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Anyone know, how to fix it? Header is good, i copy it from firefox network tools. I need to send POST request, not GET. Code written in python 3.7
  On i send it post from firefox, i getting normal response: </p>
  
  <pre><code>status: "ok"
  </code></pre>