title: TCL HTTP set up headers to send post request
body: <p>I am totally new to tcl.</p>
  
  <p>I am trying to send a post request to a server. Those are the headers I am trying to send :</p>
  
  <pre><code>"POST test HTTP/1.1"
  "Content-Type:application/x-www-form-urlencoded"
  "keep-alive:true"
  "Authorization: Basic khjkjkhkhkfzxc"
  "client: amin"
  "Content-Length:10"
  "ggggsis"
  </code></pre>
  
  <p>My code is : </p>
  
  <pre><code>set bs "Basic khjkjkhkhkfzxc"
  set hd [list Authorization $bs]
  set tk[http::geturl $url  -headers $hd]
  
  set res [http::data $tk]
  http::cleanup $tk
  
  return $tk
  </code></pre>
  
  <p>Why doesn't this work? Where is my mistake? And how to fix it?</p>
  
  <p>Your help is much appreciated. Thanks</p>
  
  <p><strong>EDIT</strong>: I created a small server socket to display my request and here is my new code for post:</p>
  
  <pre><code>set bs "Basic gfhfghfdhgf"
      set hd [list Authorization $bs]
      set token [http::geturl $url  -headers $hd -query [::http::formatQuery blabla blablo] -type "text/xml"]
      puts "done"
      set postStat [http::status $token]
      set postResp [http::data $token]
      puts $postResp
      puts "ok"
      puts $postStat
  </code></pre>
  
  <p>Here is what it is being displayed</p>
  
  <pre><code>Accepted connection from 127.0.0.1 at Fri Aug  1 10:51:22 EDT 2014
  POST /QUEUE/test HTTP/1.0
  Accept: */*
  Host: localhost:9999
  User-Agent: Tcl http client package 2.5.0
  Authorization: Basic ZGVmYXVsdCJkZWZhdWx0
  Content-Type: text/xml
  Content-Length: 13
  </code></pre>
  
  <p>The problem is that the program send the post but is doesn't move out from 
  <code>set token [http::geturl $url  -headers $hd -query [::http::formatQuery blabla blablo] -type "text/xml"],</code> </p>
  
  <p>And the httpget query is never being sent ("done" is never being printed and the content of the query doesn't print in the server side)</p>
  
  <p>Sorry for if I explain things badly.</p>
  
  <p>Thanks</p>