package require http 2

#example with -type

set url "http://www.google.ch/search"
set query [::http::formatQuery [list q "http+geturl"]]
set result [::http::geturl $url -query "?$query" \
    -headers [list "Content-Type" "text/xml; charset=utf-8"] \
    -type "text/xml"]

#http looks like this:
# Content-Type is twice one with charset one without
#
# Trace from wireshark:
#
#POST /search HTTP/1.1
#Accept: */*
#Host: www.google.ch
#User-Agent: Tcl http client package 2.7.5
#Connection: close
#Content-Type: text/xml; charset=utf-8			<-------
#Content-Type: text/xml					<-------
#Content-Length: 18

###################################3
# without -type

set url "http://www.google.ch/search"
set query [::http::formatQuery [list q "http+geturl"]]
set result [::http::geturl $url -query "?$query" \
    -headers [list "Content-Type" "text/xml; charset=utf-8"]]

#http looks like this:
# Content-Type is twice one with charset one without but with the default value:
# "application/x-www-form-urlencoded"
#
# Trace from wireshark:
#
#POST /search HTTP/1.1
#Accept: */*
#Host: www.google.ch
#User-Agent: Tcl http client package 2.7.5
#Connection: close
#Content-Type: text/xml; charset=utf-8			<--------
#Content-Type: application/x-www-form-urlencoded	<--------
#Content-Length: 18
