Tcl Source Code

Artifact [2e35876e60]
Login

Artifact 2e35876e6026bde606d6ba5f9ec94aff1ce828a2:

Attachment "testenc.tcl" to ticket [3391977fff] added by mzi 2011-08-15 21:26:34.
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