summaryrefslogtreecommitdiff
path: root/module/web
AgeCommit message (Collapse)AuthorFilesLines
2016-05-22http: Accept empty reason phrases.Ludovic Courtès1-5/+20
Fixes <http://bugs.gnu.org/22273>. Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>. * module/web/http.scm (read-header-line): New procedure. (read-response-line): Use it instead of 'read-line*'. * test-suite/tests/web-http.test ("read-response-line"): Add test.
2016-05-22web: Gracefully handle premature EOF when reading chunk header.Ludovic Courtès1-9/+16
* module/web/http.scm (read-chunk-header): Return 0 when 'read-line' returns EOF.
2016-05-22web: Fix 'close' method of delimited input ports.Ludovic Courtès1-2/+2
* module/web/response.scm (make-delimited-input-port)[close]: Replace erroneous self-recursive call with a call to 'close-port'. * test-suite/tests/web-response.test ("example-1")["response-body-port + close"]: New test.
2016-05-22web: Export 'server-impl' procedures and the 'http' server implementation.Ludovic Courtès2-3/+13
* module/web/server.scm: Export the 'server-impl' procedures. * module/web/server/http.scm: Export 'http'.
2016-05-22http: Do not buffer HTTP chunks.Ludovic Courtès1-34/+32
Fixes <http://bugs.gnu.org/19939>. * module/web/http.scm (read-chunk, read-chunk-body): Remove. (make-chunked-input-port)[next-chunk, buffer-, buffer-size, buffer-pointer]: Remove. [chunk-size, remaining]: New variables. [read!]: Rewrite to write directly to BV. * test-suite/tests/web-http.test ("chunked encoding")["reads chunks without buffering", "reads across chunk boundaries"]: New tests.
2016-04-11make-chunked-output-port buffering fixAndy Wingo1-7/+11
* module/web/http.scm (make-chunked-output-port): Add #:buffering argument, defaulting to 1200 (some random value under the MTU). This will force a flush every so often, and not every character as would otherwise be the case after this port rewrite.
2016-04-04Use symbols instead of _IONBF values as args to setvbufAndy Wingo2-2/+2
* libguile/ports.c (scm_setvbuf): Use the symbols `none', `line', and `block' instead of the values `_IONBF', `_IOLBF', and `_IOFBF'. * NEWS: Update. * doc/ref/posix.texi (Ports and File Descriptors): Update setvbuf documentation. * module/ice-9/deprecated.scm (define-deprecated): New helper. (_IONBF, _IOLBF, _IOFBF): Define deprecated values. * benchmark-suite/benchmarks/read.bm ("read"): * benchmark-suite/benchmarks/uniform-vector-read.bm ("uniform-vector-read!"): * libguile/r6rs-ports.c (cbip_fill_input): * module/system/base/types.scm (%ffi-memory-backend): * module/web/client.scm (open-socket-for-uri): * module/web/server/http.scm (http-read): * test-suite/tests/ports.test ("pipe, fdopen, and line buffering"): ("setvbuf"): * test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports"): Update to use non-deprecated interfaces.
2016-01-07web: Be less strict when parsing entity tags.Andy Wingo1-4/+9
* module/web/http.scm (parse-entity-tag): Be less strict, accepting unquoted strings as well. * test-suite/tests/web-http.test ("response headers"): Add a test for etag parsing.
2014-11-01web: Location header is URI-reference; better URI-reference supportAndy Wingo4-45/+70
* module/web/uri.scm (validate-uri): Add reference? keyword argument, for validating references. (build-uri): Clarify comments to indicate that the result is an absolute URI. (build-uri-reference): New interface, to build URI-references. (string->uri-reference): Rename from string->uri*. Fix fragment parsing to not include the #. (string->uri): Adapt to string->uri-reference name change. * module/web/request.scm (request-absolute-uri): Add default-scheme optional argument. Use it if the request-uri has no scheme, or error. * module/web/http.scm (write-uri): Reflow to use "when". Fix writing of URI-reference instances. (declare-uri-reference-header!): Rename from declare-relative-uri-header!. Use string->uri-reference. ("Location"): Declare as a URI-reference header, as per RFC 7231. * module/web/client.scm (open-socket-for-uri): Handle the case in which there is no URI scheme. * test-suite/tests/web-http.test: * test-suite/tests/web-uri.test: Add tests.
2014-09-30Merge branch 'stable-2.0'Mark H Weaver1-3/+1
Conflicts: benchmark-suite/benchmarks/ports.bm libguile/async.h libguile/bytevectors.c libguile/foreign.c libguile/gsubr.c libguile/srfi-1.c libguile/vm-engine.h libguile/vm-i-scheme.c module/Makefile.am module/language/tree-il/analyze.scm module/language/tree-il/peval.scm module/scripts/compile.scm module/scripts/disassemble.scm test-suite/tests/asm-to-bytecode.test test-suite/tests/peval.test test-suite/tests/rdelim.test
2014-05-23web: Keep the default size for the client's in-kernel receive buffer.Ludovic Courtès1-3/+1
Fixes <http://bugs.gnu.org/15368>. * module/web/client.scm (open-socket-for-uri): Remove call to 'setsockopt'. Contrary to what the comment said, its effect was to shrink the receive buffer from 124 KiB (the default size, per /proc/sys/net/core/rmem_default on Linux-based systems) to 12 KiB.
2014-02-07Merge commit 'a5cbbaa66a2491453db0edff9b0cb592a98f61bf'Andy Wingo1-4/+4
2014-01-21Write out HTTP Basic auth headers correctly.Mark H Weaver1-4/+4
Fixes <http://bugs.gnu.org/14370>. Reported by Atom X Zane <atomx@deadlyhead.com>. * module/web/http.scm (write-credentials): Handle the Basic auth scheme correctly. * test-suite/tests/web-http.test (pass-if-round-trip): Use 'pass-if-equal' for better error reporting. ("request headers"): Add tests. * THANKS: Add "Atom X Zane" to bug fix section.
2014-01-21Merge branch 'stable-2.0'Mark H Weaver1-11/+16
Conflicts: libguile/read.c test-suite/tests/web-response.test
2014-01-20Add support for content-dispositionAndy Wingo1-1/+25
* module/web/http.scm ("Content-Disposition"): Add a parser and serializer. Defined in RFC2616 section 19.5.1. * test-suite/tests/web-http.test ("entity headers"): New test case.
2014-01-18Add support for content-dispositionAndy Wingo1-1/+25
* module/web/http.scm ("Content-Disposition"): Add a parser and serializer. Defined in RFC2616 section 19.5.1. * test-suite/tests/web-http.test ("entity headers"): New test case.
2014-01-15web: Don't throw if a response is longer than its Content-Length says.Ludovic Courtès1-11/+16
* module/web/response.scm (make-delimited-input-port): Read at most LEN bytes from PORT, instead of trying to read more and returning an error if more is available. Try again when 'get-bytevector-n!' return zero. * test-suite/tests/web-response.test (example-1): Add garbage after the body itself.
2013-11-28Merge commit '8571dbde639e0ee9885bad49c9e180474bd23646'Andy Wingo1-0/+2
Conflicts: libguile/procprop.c
2013-11-19Web: accept "UTC" as the zone offset in date headers.Mark H Weaver1-0/+2
Fixes <http://bugs.gnu.org/14128>. Reported by Aleix Conchillo Flaqué <aconchillo@gmail.com>. * module/web/http.scm (parse-zone-offset): Accept "UTC".
2013-09-13Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver2-21/+21
Conflicts: module/srfi/srfi-9.scm module/web/server.scm
2013-09-12Web: Use functional setters in extend-request and extend-response.Mark H Weaver2-14/+9
* module/web/client.scm (extend-request): * module/web/server.scm (extend-response): Reimplement using functional setters.
2013-09-12Web client+server: Add Content-Length header for empty bodies.Mark H Weaver2-2/+4
* module/web/client.scm (sanitize-request): Add a Content-Length header if a body if given, even if the body is empty. * module/web/server.scm (sanitize-response): Add a Content-Length header if a body if given, even if the body is empty.
2013-09-10web client: HTTP methods are symbols, not strings.Mark H Weaver1-9/+9
* module/web/client.scm (request, http-get, http-head, http-post, http-put, http-delete, http-trace, http-options): HTTP methods are symbols.
2013-09-10Fix extend-request to preserve method and meta.Alexandru Cojocaru1-2/+5
* module/web/client.scm (extend-request): Preserve method and meta.
2013-08-23Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-6/+3
2013-08-19`write-request-line' always prints a path component.Ian Price1-6/+3
* module/web/http.scm (write-request-line): Always write "/" when path is empty, regardless of query. * test-suite/tests/web-http.test ("write-request-line"): Add test.
2013-07-18Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver2-3/+36
2013-07-16Add support for HTTP proxies.Mark H Weaver2-3/+36
* module/web/http.scm (http-proxy-port?, set-http-proxy-port?!): New exported procedures. (write-request-line): If we're using an http proxy, write an absolute-URI in the request line. * module/web/client.scm: Import (web http). (current-http-proxy): New exported parameter. (open-socket-for-uri): If 'current-http-proxy' is not false, connect to the proxy instead of the URI host, and use 'set-http-proxy-port?!' to make note of that fact. * doc/ref/web.texi (Web Client): Document 'current-http-proxy'.
2013-07-16Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-5/+6
Conflicts: libguile/keywords.c libguile/vm.c
2013-05-02web: uri-encode hexadecimal percent-encoding is now uppercaseAleix Conchillo Flaque1-5/+6
* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH is now uppercased as suggested by RFC3986: "For consistency, URI producers and normalizers should use uppercase hexadecimal digits for all percent-encodings." * test-suite/tests/web-uri.test ("encode"): update tests.
2013-03-28Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver4-52/+108
Conflicts: configure.ac libguile/deprecated.c libguile/deprecated.h libguile/filesys.h libguile/fluids.c libguile/fports.c libguile/gc.c libguile/guile.c libguile/numbers.c libguile/objcodes.c libguile/r6rs-ports.c libguile/smob.c libguile/socket.c libguile/threads.h module/language/scheme/decompile-tree-il.scm module/language/tree-il/peval.scm test-suite/tests/syncase.test
2013-03-27web http: parse numeric time zones in headersDaniel Hartwig1-15/+46
* module/web/http.scm (parse-zone-offset, normalize-date): New procedures. (parse-rfc-822-date, parse-rfc-850-date, parse-date): Update. * test-suite/tests/web-http.test ("general headers"): Add test. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2013-03-16http: support IP-literal (IPv6 address) in Host headerDaniel Hartwig1-6/+20
* module/web/http.scm ("Host"): Parse and write IP-literals treating escapes as uri module does: remove brackets on parse, replace them on write. * test-suite/tests/web-http.test ("request headers"): Add tests.
2013-03-16minor tweaks to web documentationDaniel Hartwig4-24/+22
* doc/ref/web.texi: Say `World Wide Web'; the hyphenated form is almost never used (c.f. w3.org). General predicate arguments are named `obj'. Fill in arguments omitted from some procedure definitions (e.g. `request-method'). Minor tweaks, such as using en-dash and missing markup as appropriate. Wrap very long deffn lines. * module/web/*.scm: Expand texinfo markup in doc strings. Synchronize with changes in web.texi.
2013-03-10fix response-body-port for responses without content-lengthJason Earl1-7/+20
* module/web/response.scm (response-body-port): Correctly handle cases in which EOF terminates the body.
2013-01-23merge stable-2.0Andy Wingo2-6/+5
There are some bugs with command-line handling that will be sorted out with the next commit.
2013-01-22add read-string and read-string! to (ice-9 rdelim)Andy Wingo1-2/+2
* module/ice-9/rdelim.scm (read-string!, read-string): New functions. * test-suite/tests/rdelim.test: Add tests. * doc/ref/api-io.texi: Add docs. * module/ice-9/iconv.scm: * module/rnrs/io/ports.scm: * module/web/uri.scm: Use the new functions.
2013-01-21Fix http-get* deprecation noteAndy Wingo1-4/+3
* module/web/client.scm (http-get*): Fix deprecation warning. Thanks to Daniel Hartwig for the report.
2013-01-15Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo4-107/+293
There is a failing test due to a scm_from_utf8_stringn bug brought out by the iconv test that will be fixed in the next commit. Conflicts: libguile/deprecated.h module/ice-9/deprecated.scm
2013-01-11Add http-post, http-put, et ceteraAndy Wingo1-56/+269
* module/web/client.scm (ensure-uri): New helper. (open-socket-for-uri): Accept a URI as a string or as a URI object. (extend-request, sanitize-request): New helpers, like the corresponding functions in (web server). (decode-response-body): Add a reference to the HTTP/1.1 spec, and use (ice-9 iconv). (request): New helper, factoring all aspects of sending an HTTP request and getting a response. (http-get): Redefine in terms of http-get. Deprecate the #:extra-headers argument in favor of #:headers. Allow a body. Add a #:streaming? argument, subsuming the functionality of http-get*. (http-get*): Deprecate. (http-head, http-post, http-put, http-delete, http-trace) (http-options): Define interfaces for all HTTP verbs. * test-suite/tests/web-client.test: Add tests. * doc/ref/web.texi: Update documentation. Thanks to Gregory Benison for the initial patch.
2013-01-11read-response-body always returns bytevector or #fAndy Wingo1-2/+8
* module/web/response.scm (read-response-body): Fix to always return either a bytevector or #f. Previously, reading a 0-length body could return the EOF object.
2013-01-11remove (web http) TODO listAndy Wingo1-7/+0
* module/web/http.scm: Remove outdated TODO list.
2013-01-11(web server) uses (ice-9 iconv)Andy Wingo1-37/+3
* module/web/server.scm (sanitize-response): Use the procedures from (ice-9 iconv) to encode the response.
2013-01-07Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver6-170/+292
Conflicts: GUILE-VERSION libguile/posix.c module/ice-9/eval.scm test-suite/tests/cse.test
2013-01-07http-get: don't shutdown write end of socketAndy Wingo2-5/+13
* module/web/http.scm ("Connection"): Write the "close" token in lower-case. * module/web/client.scm (http-get): Don't shutdown the writing side of the pipe if we are not doing a keepalive, as this may prevent the request from being sent at all. Prevented http://friendfeed.com/ from being correctly fetched.
2012-12-17web: Correctly detect "No route to host" conditions.Ludovic Courtès1-11/+14
* module/web/client.scm (open-socket-for-uri): Delete addrinfos with the same address. Always open SOCK_STREAM/IPPROTO_IP sockets. Fix the error handler's condition to determine what to do. Reported by Nikita Karetnikov <nikita.karetnikov@gmail.com> at <http://lists.gnu.org/archive/html/bug-guix/2012-12/msg00150.html>.
2012-11-28web: Add `http-get*'.Ludovic Courtès1-1/+24
* module/web/client.scm (http-get*): New procedure. * doc/ref/web.texi (Web Client): Document it.
2012-11-28web: Add `response-body-port'.Ludovic Courtès1-11/+59
* module/web/response.scm (make-delimited-input-port, response-body-port): New procedures. (read-response-body): Use `response-body-port'. * test-suite/tests/web-response.test ("example-1")["response-body-port"]: New test. ("example-2")["response-body-port"]: New test.
2012-11-28web: Export `text-content-type?'.Ludovic Courtès2-7/+10
* module/web/client.scm (text-type?): Remove. (decode-response-body): Use `text-content-type?'. * module/web/response.scm (text-content-type?): New procedure. * doc/ref/web.texi (Responses): Document it.
2012-11-27web client: correctly handle uri-query, etc. in relative URI headersDaniel Hartwig2-19/+23
* module/web/uri.scm (uri-pat): Make scheme part optional. (string->uri*): New private procedure to also parse relative URIs. * module/web/http.scm (declare-relative-uri-header!): Use that.