75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
-
+
|
# RESULT to the HTTP response body, and JR to a Tcl dict conversion of
# the response body.
#
# Returns the status code from the HTTP header.
proc fossil_http_json {url {cookie "Muppet=Monster"} args} {
global RESULT JR
set request "GET $url HTTP/1.1\r\nHost: localhost\r\nUser-Agent: Fossil-http-json\r\nCookie: $cookie"
set RESULT [fossil_maybe_answer $request http {*}$args]
set RESULT [fossil_maybe_answer $request http {*}$args --ipaddr 127.0.0.1]
set head ""; set body ""; set status "--NO_MATCH--"
regexp {(?w)(.*)^\s*$(.*)} $RESULT dummy head body
regexp {^HTTP\S+\s+(\d\d\d)\s+(.*)$} $head dummy status msg
if {$status eq "200"} {
set JR [json2dict $body]
}
return $status
|