title: Character encoding in a GET request with http.client lib (Python)
body: <p>I am a beginner in python and I coded this little script to send an HTTP GET request on my local server (localhost). It works great, except that I wish I could send Latin characters such as accents.</p>
  
  <pre><code>import http.client
  
  httpMethod = "GET"
  url = "localhost"
  params = "Hello World"
  
  def httpRequest(httpMethod, url, params):
      conn = http.client.HTTPConnection(url)
      conn.request(httpMethod, '/?param='+params)
      conn.getresponse().read()
      conn.close()
      return
  
  httpRequest(httpMethod, url, params)
  </code></pre>
  
  <p>When I insert the words with accent in my parameter "params", this is the error message that appears:</p>
  
  <p><em>UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 14: ordinal not in range(128)</em></p>
  
  <p>I don't know if there is a solution using http.client library but I think so. When I look in the documentation http.client, I can see this:</p>
  
  <p><strong>HTTPConnection.request</strong></p>
  
  <p>Strings are encoded as ISO-8859-1, the default charset for HTTP</p>