1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

28 commits

Author SHA1 Message Date
Ludovic Courtès
b9f6e89a27 http: Accept date strings with a leading space for hours.
Fixes <http://bugs.gnu.org/23421>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* module/web/http.scm (parse-rfc-822-date): Add two clauses for hours
with a leading space.
* test-suite/tests/web-http.test ("general headers"): Add two tests.
2016-05-22 20:14:34 +02:00
Ludovic Courtès
f53145d41c http: Accept empty reason phrases.
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-22 20:02:37 +02:00
Ludovic Courtès
3829047ec7 http: Test that responses lacking CR/LF are rejected.
* test-suite/tests/web-http.test ("read-response-line")["missing
CR/LF"]: New test.
2016-05-22 20:02:36 +02:00
Ludovic Courtès
0bcf5d78ec web: Gracefully handle premature EOF when reading chunk header.
* module/web/http.scm (read-chunk-header): Return 0 when 'read-line'
  returns EOF.
2016-05-22 19:49:33 +02:00
Ludovic Courtès
751a55e355 http: Do not buffer HTTP chunks.
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-05-22 18:43:28 +02:00
Ludovic Courtès
c6d88d1234 tests: Use 'pass-if-equal' in web-http chunked encoding tests.
* test-suite/tests/web-http.test ("chunked encoding"): Use
  'pass-if-equal' where appropriate.
2016-05-22 18:40:43 +02:00
Andy Wingo
6d7c09c8a9 web: Be less strict when parsing entity tags.
* 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.
2016-01-07 10:53:57 +01:00
Andy Wingo
18c44b29e4 web: Location header is URI-reference; better URI-reference support
* 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-11-01 15:36:56 +01:00
Mark H Weaver
d0d8c872af Write out HTTP Basic auth headers correctly.
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-21 16:11:04 -05:00
Andy Wingo
6f4cc6a31e Add support for content-disposition
* 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-20 19:03:58 -05:00
Ian Price
20d28792b3 `write-request-line' always prints a path component.
* 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-08-19 10:43:02 +01:00
Daniel Hartwig
ffc8eca636 web http: parse numeric time zones in headers
* 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-27 18:09:49 +01:00
Daniel Hartwig
b1c46fd30a http: support IP-literal (IPv6 address) in Host header
* 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-16 19:53:07 +08:00
Daniel Hartwig
2e08ff38b7 add tests for read-request-line, etc.
* test-suite/web/web-http.test ("read-request-line"):
  ("write-request-line", "read-response-line", "write-response-line"):
  Add.
2013-03-16 17:56:08 +08:00
Ian Price
312e79f8d5 Add HTTP Chunked Encoding support to web modules.
* doc/ref/web.texi(Transfer Codings): New subsection for transfer codings.
* module/web/http.scm(make-chunked-input-port,
  make-chunked-output-port): New procedures.
* module/web/response.scm (read-response-body): Handle chunked responses.
* test-suite/tests/web-response.test: Add test.
* test-suite/tests/web-http.test: Add tests.

afd
2012-07-06 22:18:12 +02:00
Andy Wingo
61fe8eafc2 HTTP: Fix qstring writing of cache-extension values
* module/web/http.scm ("Cache-Control"): Write string values using the
  default val writer, to get quoting correct.

* test-suite/tests/web-http.test (pass-if-round-trip): New helper.
  ("general headers"): Check that cache-extensions round trip properly.
2011-12-22 08:18:05 -05:00
Daniel Hartwig
321770b2a3 Extend handling of "Cache-Control" header.
* module/web/http.scm ("Cache-Control"): Value for `max-stale' is
  optional.  Strict validation for value-less directives (`no-store',
  etc.).  String values optional for "cache-extension" directives.
* test-suite/tests/web-http.test: Value for `max-stale' is optional.
2011-12-22 08:00:57 -05:00
Daniel Hartwig
4855c63441 web-http.test validates headers
* test-suite/tests/web-http.test (pass-if-parse): Validate header values
  as well.
2011-11-23 23:35:20 +01:00
Ian Price
cb7bcfca35 RFC 822 allows single digit days of the month
* module/web/http.scm (parse-rfc-822-date): Add single digit day
  conditional.
* test-suite/tests/web-http.test("general headers"): Add test.
2011-09-10 11:12:04 -07:00
Andy Wingo
ecfb7167cb parse credentials and challenges
* module/web/http.scm (parse-credentials, validate-credentials)
  (write-credentials, parse-challenge, parse-challenges)
  (validate-challenges, write-challenge, write-challenges)
  (declare-credentials-header!, declare-challenge-list-header!): New
  helpers.
  ("Authorization", "Proxy-Authorization"): Parse out credentials.
  ("Proxy-Authenticate", "WWW-Authenticate"): Parse out challenges.
2011-01-10 09:31:29 -08:00
Andy Wingo
94f16a5b8f more symbols in (web http)
* module/web/http.scm (declare-symbol-list-header!): New helper.
  ("Connection"): Redefine as a header list.
  ("Allow", "Content-Encoding", "Accept-Ranges"): Redefine as symbol
  lists.

* test-suite/tests/web-http.test:
* test-suite/tests/web-response.test: Adapt tests.
2011-01-08 21:32:14 -08:00
Andy Wingo
0acc595b94 (web http): keys are always symbols
* module/web/http.scm (parse-media-type): Parse media types as symbols.
  (parse-key-value-list, parse-param-component, parse-param-list):
  Change kons to val-parser. Always parse keys as symbols, and always
  either cons, if there is a val, or just have the key, if there is no
  val.  Easier to explain and just as correct.
  (declare-param-list-header!, declare-key-value-list-header!): Adapt to
  key-list and param-list kons change.
  ("Cache-Control", "Pragma", "Transfer-Encoding", "Accept", "Expect")
  ("TE"): Likewise, adapt.
  ("Content-Type"): Param keys are symbols.
2011-01-08 20:50:46 -08:00
Andy Wingo
be1be3e597 (web http): header names always represented as symbols
* module/web/http.scm (declare-header!): No need to specify `sym', as it
  can be derived from `name'. Change to take parser, validator, and
  writer as positional arguments, and multiple? as a keyword.
  (parse-header): Change to take the header as a symbol already, and
  just return the parsed value.  All headers are symbols now, including
  unknown headers.  I feel OK doing this given that the symbol GC works
  now.
  (lookup-header-decl): Only look up headers by symbol.
  (read-header): Adapt to parse-header change.

  (valid-header?, write-header): Adapt to all headers being symbols.
  (split-header-names, list-of-header-names?, write-header-list):
  Represent all header names as symbols.

  (declare-opaque-header!, declare-date-header!)
  (declare-string-list-header!, declare-header-list-header!)
  (declare-integer-header!, declare-uri-header!)
  (declare-quality-list-header!, declare-param-list-header!)
  (declare-key-value-list-header!, declare-entity-tag-list-header!):
  Change to be functions instead of syntax, and no need to specify the
  symbolic name. Update all header declarations accordingly.

* module/web/request.scm (validate-headers):
* module/web/response.scm (validate-headers): Adapt to all headers being
  symbols.

* test-suite/tests/web-http.test (pass-if-parse, pass-if-any-error)
  (pass-if-parse-error): Update for parse-header change.
  ("general headers"): Update header list examples to be all symbols.
2011-01-08 10:54:07 -08:00
Andy Wingo
adc91e41bf http: lists of header names parse better
* module/web/http.scm (list-of-strings?, write-list-of-strings): Move
  definitions up.
  (split-header-names, list-of-header-names?, write-header-list): New
  helpers.
  (declare-header-list-header): New helper.
  (cache-control): Use split-header-names for private and no-cache.
  (trailer): Use declare-header-list-header to parse known headers to
  symbols.
  (vary): Likewise, use split-header-names et al.

* test-suite/tests/web-http.test ("general headers"): Add a test.
2010-12-16 18:12:14 +01:00
Andy Wingo
25731543d4 better cache-control: private, no-cache parsing
* module/web/http.scm (cache-control): Parse private and no-cache
  better.
* test-suite/tests/web-http.test ("general headers"): Update.
2010-12-16 17:56:03 +01:00
Andy Wingo
9eed1010e7 leniency regarding quality values in http.scm
* module/web/http.scm: Add commentary.
  (parse-quality): Allow .NNN to be interpreted as 0.NNN.

* test-suite/tests/web-http.test ("request headers"): Add a test.
2010-12-06 13:52:56 +01:00
Andy Wingo
7aa54882cf (web http) parses content-type as "foo/bar", not "foo" "bar"
* module/web/http.scm (parse-media-type, validate-media-type,
  (content-type): Change to represent media types as ("foo/bar" ("param"
  . "val") ...) instead of ("foo" "bar" ("param" . "val") ...). Seems to
  be more in line with what people expect.

* test-suite/tests/web-http.test ("entity headers"): Add content-type
  test.

* test-suite/tests/web-response.test ("example-1"): Adapt expected
  parse.
2010-11-13 18:25:34 +01:00
Andy Wingo
440840c113 add HTTP module
* module/web/http.scm: New module, declares known HTTP headers, and
  their parsers and unparsers.

* test-suite/tests/web-http.test: Add test suite.

* module/Makefile.am:
* test-suite/Makefile.am: Adapt.
2010-11-04 22:52:47 +01:00