1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

web client: HTTP methods are symbols, not strings.

* module/web/client.scm (request, http-get, http-head, http-post,
  http-put, http-delete, http-trace, http-options): HTTP methods are
  symbols.
This commit is contained in:
Mark H Weaver 2013-09-10 01:39:52 -04:00
parent 9c85fd0221
commit 55e29bb55b

View file

@ -207,7 +207,7 @@ as is the case by default with a request returned by `build-request'."
(define* (request uri #:key (define* (request uri #:key
(body #f) (body #f)
(port (open-socket-for-uri uri)) (port (open-socket-for-uri uri))
(method "GET") (method 'GET)
(version '(1 . 1)) (version '(1 . 1))
(keep-alive? #f) (keep-alive? #f)
(headers '()) (headers '())
@ -230,7 +230,7 @@ as is the case by default with a request returned by `build-request'."
(force-output (request-port request)) (force-output (request-port request))
(let ((response (read-response port))) (let ((response (read-response port)))
(cond (cond
((equal? (request-method request) "HEAD") ((eq? (request-method request) 'HEAD)
(unless keep-alive? (unless keep-alive?
(close-port port)) (close-port port))
(values response #f)) (values response #f))
@ -285,7 +285,7 @@ true)."
(issue-deprecation-warning (issue-deprecation-warning
"The #:extra-headers argument to http-get has been renamed to #:headers. " "The #:extra-headers argument to http-get has been renamed to #:headers. "
"Please update your code.")) "Please update your code."))
(request uri #:method "GET" #:body body (request uri #:method 'GET #:body body
#:port port #:version version #:keep-alive? keep-alive? #:port port #:version version #:keep-alive? keep-alive?
#:headers headers #:decode-body? decode-body? #:headers headers #:decode-body? decode-body?
#:streaming? streaming?)) #:streaming? streaming?))
@ -322,7 +322,7 @@ true)."
#:streaming? streaming?))) #:streaming? streaming?)))
(define-http-verb http-head (define-http-verb http-head
"HEAD" 'HEAD
"Fetch message headers for the given URI using the HTTP \"HEAD\" "Fetch message headers for the given URI using the HTTP \"HEAD\"
method. method.
@ -335,7 +335,7 @@ requests do not have a body. The second value is only returned so that
other procedures can treat all of the http-foo verbs identically.") other procedures can treat all of the http-foo verbs identically.")
(define-http-verb http-post (define-http-verb http-post
"POST" 'POST
"Post data to the given URI using the HTTP \"POST\" method. "Post data to the given URI using the HTTP \"POST\" method.
This function is similar to http-get, except it uses the \"POST\" This function is similar to http-get, except it uses the \"POST\"
@ -345,7 +345,7 @@ arguments that are accepted by this function.
Returns two values: the resulting response, and the response body.") Returns two values: the resulting response, and the response body.")
(define-http-verb http-put (define-http-verb http-put
"PUT" 'PUT
"Put data at the given URI using the HTTP \"PUT\" method. "Put data at the given URI using the HTTP \"PUT\" method.
This function is similar to http-get, except it uses the \"PUT\" This function is similar to http-get, except it uses the \"PUT\"
@ -355,7 +355,7 @@ arguments that are accepted by this function.
Returns two values: the resulting response, and the response body.") Returns two values: the resulting response, and the response body.")
(define-http-verb http-delete (define-http-verb http-delete
"DELETE" 'DELETE
"Delete data at the given URI using the HTTP \"DELETE\" method. "Delete data at the given URI using the HTTP \"DELETE\" method.
This function is similar to http-get, except it uses the \"DELETE\" This function is similar to http-get, except it uses the \"DELETE\"
@ -365,7 +365,7 @@ arguments that are accepted by this function.
Returns two values: the resulting response, and the response body.") Returns two values: the resulting response, and the response body.")
(define-http-verb http-trace (define-http-verb http-trace
"TRACE" 'TRACE
"Send an HTTP \"TRACE\" request. "Send an HTTP \"TRACE\" request.
This function is similar to http-get, except it uses the \"TRACE\" This function is similar to http-get, except it uses the \"TRACE\"
@ -375,7 +375,7 @@ arguments that are accepted by this function.
Returns two values: the resulting response, and the response body.") Returns two values: the resulting response, and the response body.")
(define-http-verb http-options (define-http-verb http-options
"OPTIONS" 'OPTIONS
"Query characteristics of an HTTP resource using the HTTP \"OPTIONS\" "Query characteristics of an HTTP resource using the HTTP \"OPTIONS\"
method. method.