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

23 commits

Author SHA1 Message Date
Andy Wingo
710ebfddc6 Web server and client use suspendable ports
* module/web/request.scm (write-request):
* module/web/response.scm (write-response): Use put-string instead of
  display.
2017-02-08 15:16:25 +01:00
Ludovic Courtès
d52edc05d3 web: Fix 'close' method of delimited input ports.
* 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-22 19:48:47 +02:00
Ludovic Courtès
802a25b1ed web: Don't throw if a response is longer than its Content-Length says.
* 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.
2014-01-15 23:41:49 +01:00
Daniel Hartwig
dc87126115 minor tweaks to web documentation
* 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-16 17:53:53 +08:00
Jason Earl
84dfde82ae fix response-body-port for responses without content-length
* module/web/response.scm (response-body-port): Correctly handle cases
  in which EOF terminates the body.
2013-03-10 19:23:31 +01:00
Andy Wingo
2ac3c0a590 read-response-body always returns bytevector or #f
* 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-11 15:15:43 +01:00
Ludovic Courtès
75d6c59fc2 web: Add `response-body-port'.
* 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-28 22:41:25 +01:00
Ludovic Courtès
ee2d874119 web: Export `text-content-type?'.
* 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-28 22:12:59 +01:00
Daniel Hartwig
06883ae000 syncronize web module docstrings with manual
* doc/ref/web.texi: Fix spacing.  Update with a few missing function
  descriptions.

* module/web/client.scm:
* module/web/http.scm:
* module/web/request.scm:
* module/web/server.scm:
* module/web/uri.scm: Update docstrings from manual (reworked by Ludovic
  Courtès).
2012-11-24 15:40:14 +01: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
164a78b355 web server: do not provide a response body where it is not permitted
* module/web/response.scm (response-must-not-include-body?): New
  function.

* doc/ref/web.texi: Doc the function.

* module/web/server.scm (sanitize-response): Error if we have a body,
  but the response type does not permit a body.  If we are responding to
  a HEAD request, silently drop the body.
2012-02-12 13:29:19 +01:00
Bake Timmons
91a214ebd9 Improve the usage of variable names in Scheme docstrings.
* module/ice-9/boot-9.scm:
* module/ice-9/popen.scm:
* module/ice-9/pretty-print.scm:
* module/ice-9/r4rs.scm:
* module/rnrs/io/ports.scm:
* module/texinfo/string-utils.scm:
* module/web/http.scm:
* module/web/request.scm:
* module/web/response.scm:
* test-suite/vm/run-vm-tests.scm: Make the variable names in Scheme docstrings more
  consistent.  Replace a few instances of @var with @code when appropriate.
2012-02-02 12:24:40 +01:00
Andy Wingo
6854c32480 core modules use (ice-9 binary-ports) instead of (rnrs io ports)
* module/language/assembly/compile-bytecode.scm:
* module/language/elisp/lexer.scm:
* module/web/request.scm:
* module/web/response.scm:
* module/web/server.scm:
* module/web/uri.scm: Use ice-9 binary-ports.
2011-02-18 16:01:25 +01:00
Andy Wingo
f944ee8f23 request and response cleanups
* module/web/request.scm (build-request): Make URI a positional
  argument.

* module/web/response.scm: Remove extend-response.
  (read-response): Fix a docstring.
* module/web/server.scm (extend-response): Include extend-response here,
  but not exported.
2011-01-10 22:44:41 -08:00
Andy Wingo
3475fbb572 (web response) and (web request): bodies are bytevectors
* module/web/request.scm (read-request-body, write-request-body): Rename
  from read-request-body/bytevector and
  write-request-body/bytevector.  Remove the /latin-1 variants, as they
  were unused and a bad idea.
* module/web/response.scm (read-response-body, write-response-body):
  Likewise.

* module/web/server/http.scm (http-read, http-write): Adapt to
  request/response change.

* test-suite/tests/web-request.test:
* test-suite/tests/web-response.test: Update tests.
2011-01-10 22:44:36 -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
e2d4bfea00 build-response validates headers
* module/web/response.scm (build-response): Add some validation, like
  for build-request.
2010-12-17 12:01:34 +01:00
Andy Wingo
cc1e26c2cd docstrings in (web request) and (web response)
* module/web/request.scm:
* module/web/response.scm: Add docstrings.
2010-12-16 14:48:34 +01:00
Andy Wingo
e46f69e25c fix read-{request,response}-body/latin-1
* module/web/request.scm (read-response-body/latin-1):
* module/web/response.scm (read-response-body/latin-1): Avoid the
  craziness of the read-delimited! interface and hand-roll our
  own. Fixes errors if read-delimited returns #f or EOF.
2010-12-06 15:30:45 +01:00
Andy Wingo
f3d390939b fix error handling in read-{request,response}-body/latin-1
* module/web/request.scm (read-request-body/latin-1):
* module/web/response.scm (read-response-body/latin-1): Detect short
  reads instead of returning a full buffer with the last bits zeroed
  out. (Before the make-string commit, they contained uninitialized
  memory, which was a fairly serious error.)
2010-12-04 19:45:09 +01:00
Andy Wingo
c637190203 stub fixes to http 1.0 support in the web server
* module/web/server.scm (read-client): Fix number of returned values in
  the case in which there is an error reading the client.
  (sanitize-response): Add a case to adapt the reponse to the request
  version.
  (handle-request): Sanitize the response within an error-handling
  block.
  (serve-one-client): Move sanitation out of here.

* module/web/server/http.scm (keep-alive?): A more proper detection on
  whether we should support persistent connections.

* module/web/response.scm (adapt-response-version): New routine, to
  adapt a response to a given version. Currently a stub.
2010-12-01 10:13:30 +01:00
Andy Wingo
3d95977991 add extend-response.
* module/web/response.scm (extend-response): New utility.
2010-11-13 18:30:27 +01:00
Andy Wingo
a9eeb2f461 add HTTP response module
* module/web/response.scm: New module, for HTTP responses.
* test-suite/tests/web-response.test: Test suite.

* module/Makefile.am:
* test-suite/Makefile.am: Adapt.
2010-11-05 00:31:40 +01:00