summaryrefslogtreecommitdiffstats
path: root/library/http/http.tcl
diff options
context:
space:
mode:
authormax <max@tclers.tk>2013-04-04 17:08:43 (GMT)
committermax <max@tclers.tk>2013-04-04 17:08:43 (GMT)
commitba5ae0ab74c4217f0a951b0eb3edf223022af5c5 (patch)
treea479f28ec1ec1dfebe670ae7fe82aa6f2d50d2b7 /library/http/http.tcl
parentac66ecde08cacbe613154be42c2bc55c2a513435 (diff)
downloadtcl-ba5ae0ab74c4217f0a951b0eb3edf223022af5c5.zip
tcl-ba5ae0ab74c4217f0a951b0eb3edf223022af5c5.tar.gz
tcl-ba5ae0ab74c4217f0a951b0eb3edf223022af5c5.tar.bz2
Allow URLs that don't have a path, but a query,
e.g. http://example.com?foo=bar and bump http to 2.7.12.
Diffstat (limited to 'library/http/http.tcl')
-rw-r--r--library/http/http.tcl19
1 files changed, 14 insertions, 5 deletions
diff --git a/library/http/http.tcl b/library/http/http.tcl
index 4a517ac..98d2c5d 100644
--- a/library/http/http.tcl
+++ b/library/http/http.tcl
@@ -11,7 +11,7 @@
package require Tcl 8.4
# Keep this in sync with pkgIndex.tcl and with the install directories in
# Makefiles
-package provide http 2.7.11
+package provide http 2.7.12
namespace eval http {
# Allow resourcing to not clobber existing data
@@ -388,13 +388,16 @@ proc http::geturl {url args} {
# First, before the colon, is the protocol scheme (e.g. http)
# Second, for HTTP-like protocols, is the authority
# The authority is preceded by // and lasts up to (but not including)
- # the following / and it identifies up to four parts, of which only one,
- # the host, is required (if an authority is present at all). All other
- # parts of the authority (user name, password, port number) are optional.
+ # the following / or ? and it identifies up to four parts, of which
+ # only one, the host, is required (if an authority is present at all).
+ # All other parts of the authority (user name, password, port number)
+ # are optional.
# Third is the resource name, which is split into two parts at a ?
# The first part (from the single "/" up to "?") is the path, and the
# second part (from that "?" up to "#") is the query. *HOWEVER*, we do
# not need to separate them; we send the whole lot to the server.
+ # Both, path and query are allowed to be missing, including their
+ # delimiting character.
# Fourth is the fragment identifier, which is everything after the first
# "#" in the URL. The fragment identifier MUST NOT be sent to the server
# and indeed, we don't bother to validate it (it could be an error to
@@ -429,7 +432,7 @@ proc http::geturl {url args} {
( [^/:\#?]+ ) # <host part of authority>
(?: : (\d+) )? # <port part of authority>
)?
- ( / [^\#]*)? # <path> (including query)
+ ( [/\?] [^\#]*)? # <path> (including query)
(?: \# (.*) )? # <fragment>
$
}
@@ -472,6 +475,12 @@ proc http::geturl {url args} {
}
}
if {$srvurl ne ""} {
+ # RFC 3986 allows empty paths (not even a /), but servers
+ # return 400 if the path in the HTTP request doesn't start
+ # with / , so add it here if needed.
+ if {[string index $srvurl 0] ne "/"} {
+ set srvurl /$srvurl
+ }
# Check for validity according to RFC 3986, Appendix A
set validityRE {(?xi)
^