[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Change to write-request-line
From: |
Ian Price |
Subject: |
Change to write-request-line |
Date: |
Thu, 29 Sep 2011 20:45:24 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Hi guilers,
Two patches for the web stuff in guile. The first removes the second
definition of 'write-uri' from module/web/http.scm. No point having two
of them after all :-).
The second changes 'write-request-line' to write paths rather than full
uris. Quoth the RFC
The most common form of Request-URI is that used to identify a
resource on an origin server or gateway. In this case the absolute
path of the URI MUST be transmitted (see section 3.2.1, abs_path) as
the Request-URI, and the network location of the URI (authority) MUST
be transmitted in a Host header field.
While the RFC also says that "The absoluteURI form is REQUIRED when the
request is being made to a proxy.", reading through the code for Ruby's
Net::HTTP and Haskell's Network.HTTP, they both seem to just use the
path and not provide for this situation, so I've held back on including
a #:absolute-uri? keyword to cover this.
Any thoughts on this?
--
Ian Price
"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"
>From 90ee8b8eae09a6974959d43ce145f6565be10f90 Mon Sep 17 00:00:00 2001
From: Ian Price <address@hidden>
Date: Thu, 29 Sep 2011 02:56:03 +0100
Subject: [PATCH 1/2] Remove second definition of `write-uri'
* module/web/http.scm (write-uri): remove procedure.
---
module/web/http.scm | 28 ----------------------------
1 files changed, 0 insertions(+), 28 deletions(-)
diff --git a/module/web/http.scm b/module/web/http.scm
index 70db813..f6aa5a0 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1046,34 +1046,6 @@ three values: the method, the URI, and the version."
(parse-http-version line (1+ d1) (string-length line)))
(bad-request "Bad Request-Line: ~s" line))))
-(define (write-uri uri port)
- (if (uri-host uri)
- (begin
- (display (uri-scheme uri) port)
- (display "://" port)
- (if (uri-userinfo uri)
- (begin
- (display (uri-userinfo uri) port)
- (display #\@ port)))
- (display (uri-host uri) port)
- (let ((p (uri-port uri)))
- (if (and p (not (eqv? p 80)))
- (begin
- (display #\: port)
- (display p port))))))
- (let* ((path (uri-path uri))
- (len (string-length path)))
- (cond
- ((and (> len 0) (not (eqv? (string-ref path 0) #\/)))
- (bad-request "Non-absolute URI path: ~s" path))
- ((and (zero? len) (not (uri-host uri)))
- (bad-request "Empty path and no host for URI: ~s" uri))
- (else
- (display path port))))
- (if (uri-query uri)
- (begin
- (display #\? port)
- (display (uri-query uri) port))))
(define (write-request-line method uri version port)
"Write the first line of an HTTP request to @var{port}."
--
1.7.6.2
>From de698292c69e0073454107e5a1ff1f6c62d50b63 Mon Sep 17 00:00:00 2001
From: Ian Price <address@hidden>
Date: Thu, 29 Sep 2011 03:12:00 +0100
Subject: [PATCH 2/2] `write-request-line' writes absolute paths, not absolute
URIs.
* module/web/http.scm (write-request-line): RFC 2616 says that
absolute paths are used to identify resources on an origin server.
---
module/web/http.scm | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/module/web/http.scm b/module/web/http.scm
index f6aa5a0..1279acc 100644
--- a/module/web/http.scm
+++ b/module/web/http.scm
@@ -1051,7 +1051,10 @@ three values: the method, the URI, and the version."
"Write the first line of an HTTP request to @var{port}."
(display method port)
(display #\space port)
- (write-uri uri port)
+ (let ((path (uri-path uri)))
+ (if (string-null? path)
+ (display "/" port)
+ (display path port)))
(display #\space port)
(write-http-version version port)
(display "\r\n" port))
--
1.7.6.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Change to write-request-line,
Ian Price <=