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

208 commits

Author SHA1 Message Date
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
Mark H Weaver
fa980bcc0f Merge remote-tracking branch 'origin/stable-2.0'
Moved scm_i_struct_hash from struct.c to hash.c and made it static.

The port's alist is now a field of 'scm_t_port'.

Conflicts:
	libguile/arrays.c
	libguile/hash.c
	libguile/ports.c
	libguile/print.h
	libguile/read.c
2012-10-30 23:46:31 -04:00
Ludovic Courtès
f865ffaab1 web: Fix possible file descriptor leak in `open-socket-for-uri'.
* module/web/client.scm (open-socket-for-uri): Always close S in the
  `system-error' handler.
2012-10-13 21:13:10 +02:00
Ludovic Courtès
d74fcce9b9 web: Pass `AI_NUMERICSERV' when given a port number.
* module/web/client.scm (open-socket-for-uri)[addresses]: Pass
  AI_NUMERICSERV as the `getaddrinfo' hint when (uri-port URI) is true.
2012-10-12 23:21:39 +02:00
Ludovic Courtès
2663411bd7 web: Change `http-get' to try all the addresses for the given URI.
* module/web/client.scm (open-socket-for-uri): Try all the addresses
  returned by `getaddrinfo' until one succeeds.
2012-10-12 23:21:39 +02:00
Ian Price
866210bf24 Fix uri-encoding for strings with no unreserved chars
* module/web/uri.scm (uri-encode): Change test to check for unreserved
  chars instead of reserved chars.
* test-suite/tests/web-uri.test ("encode"): Add test.
2012-08-26 23:36:36 +02:00
Ian Price
b401fe7169 Fix uri-encoding for octets 0-15
* module/web/uri.scm (uri-encode): All encoded octets should be of the
  form % HEXDIGIT HEXDIGIT.
* test-suite/tests/web-uri.test ("encode"): Add test.
2012-08-26 23:35:33 +02:00
Andy Wingo
4bfe73072b Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	GUILE-VERSION
2012-07-24 23:22:41 +02:00
Ian Price
64ead01db7 Document and export `declare-opaque-header!'
* module/web/http.scm (declare-opaque-header!): Add docstring. New export.
* doc/ref/web.texi (HTTP): Add documentation.
2012-07-06 22:18:13 +02: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
2aed2667fc Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	libguile/expand.c
	libguile/hashtab.c
	libguile/ports.c
	libguile/vectors.c
	libguile/weaks.c
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il/effects.scm
	module/language/tree-il/fix-letrec.scm
	module/language/tree-il/peval.scm
	test-suite/tests/peval.test
2012-07-06 16:52:54 +02:00
Andy Wingo
3fabb2d2be more uri-related ipv6 fixes
* module/web/uri.scm (ipv6-regexp): IPv6 numeric addresses do not have
  brackets.  It's only in URIs that they have them.
  (ipv6-host-pat, authority-regexp, parse-authority): Refactor ipv6
  detection to fix a bug with |, and to extract IPv6 hosts from their
  brackets.  This way we can pass the uri-host directly to inet-pton.
  (uri->string): If the host contains a `:', assume it is ipv6 and add
  brackets.

* test-suite/tests/web-uri.test ("build-uri"): Adapt tests to assume
  that the address returned by uri-host and passed to build-uri #:host
  does not have brackets.
2012-07-06 13:13:19 +02:00
Daniel Hartwig
81e7210f14 enhance IPv6 support
* module/web/uri.scm (valid-host?): Support dotted-quad notation
  in IPv6 addresses.
  (parse-authority): Support IPv6 literals.
* test-suite/tests/web-uri.test: Add and fix tests.
2012-07-06 12:33:41 +02:00
Daniel Hartwig
274e2eecf1 support URIs with domain names starting with numbers
* module/web/uri.scm (valid-host?): Fix regexp to support
domain names starting with numbers.
* test-suite/tests/web-uri.scm: Add tests for above and
IP literals.
2012-07-06 12:33:16 +02:00
Andy Wingo
da03005a2a add bad-request printer
* module/web/request.scm (bad-request-printer): Add printer for these
  exceptions.
2012-03-22 09:56:27 +01:00
Andy Wingo
1be6c7d34d add exception printers for bad-header, bad-header-component
* module/web/http.scm (bad-header-component): Throw
  'bad-header-component instead of 'bad-header.
  (bad-header-printer, bad-header-component-printer): Add exception
  printers.
2012-03-22 09:56:27 +01:00
Andy Wingo
47153f29b0 micro-optimizations to string-trim-both, and to (web http)
* libguile/srfi-13.c (scm_string_trim, scm_string_trim_right)
  (scm_string_trim_both): Take the whitespace fast-path if the char_pred
  is scm_char_set_whitespace.

* module/web/http.scm (read-header, split-and-trim, parse-quality-list):
  (parse-param-component, parse-credentials, "Content-Type"):
  (read-request-line, read-response-line): Use char-set:whitespace
  instead of char-whitespace?.  It avoids recursing into the VM.
2012-03-22 09:55:28 +01:00
Andy Wingo
d5e1f82240 Merge remote-tracking branch 'origin/stable-2.0' 2012-03-12 17:00:09 +01:00
Andy Wingo
89d45e8507 web http: fix Ma -> Mar
* module/web/http.scm (write-date): Fix serialization of Mar.  Oops.
2012-03-12 16:58:15 +01:00
Andy Wingo
9effafa444 fix bad-request-printer
* module/web/request.scm (bad-request-printer): Fix printer to expect
  args as a list.
2012-03-11 11:06:39 +01:00
Andy Wingo
8b49b6b1f5 Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	configure.ac
2012-03-11 11:06:14 +01:00
Andy Wingo
e0dc497832 add bad-request printer
* module/web/request.scm (bad-request-printer): Add printer for these
  exceptions.
2012-03-11 10:57:05 +01:00
Andy Wingo
02360ed605 web server http: 400 Bad Request on bad requests
* module/web/server/http.scm (bad-request, http-read): If an exception
  is raised while reading a response, write out a 400 Bad Request
  response before closing the port.
2012-03-11 10:29:06 +01:00
Andy Wingo
aaaa0eef9c add exception printers for bad-header, bad-header-component
* module/web/http.scm (bad-header-component): Throw
  'bad-header-component instead of 'bad-header.
  (bad-header-printer, bad-header-component-printer): Add exception
  printers.
2012-03-11 10:24:08 +01:00
Andy Wingo
4df9e5eb0f micro-optimizations to string-trim-both, and to (web http)
* libguile/srfi-13.c (scm_string_trim, scm_string_trim_right)
  (scm_string_trim_both): Take the whitespace fast-path if the char_pred
  is scm_char_set_whitespace.

* module/web/http.scm (read-header, split-and-trim, parse-quality-list):
  (parse-param-component, parse-credentials, "Content-Type"):
  (read-request-line, read-response-line): Use char-set:whitespace
  instead of char-whitespace?.  It avoids recursing into the VM.
2012-03-07 13:04:53 +01:00
Andy Wingo
3c12fc3595 micro-optimization in (web server)
* module/web/server.scm (extend-response): Micro-optimize to not mutate
  data, and to copy as little as possible.
2012-03-06 22:22:31 +01:00
Andy Wingo
7ea70f355e microoptimizations in (web uri)
* module/web/uri.scm (valid-host?): Micro-optimizations.
2012-02-22 20:40:55 +01:00
Andy Wingo
4f6e8ba7bc quick fix the quick fix 2012-02-21 16:50:55 +00:00
Andy Wingo
1868309a9e quick fix to uri parser
* module/web/uri.scm: Quick fix to not throw an error on e.g.
  http://2012.jsconf.us.
2012-02-21 16:45:24 +00:00
Andy Wingo
eec3a50867 web server: fix spurious warning
* module/web/server.scm (sanitize-response): Quick fix to the
  304-has-no-body sanitizer.
2012-02-14 17:32:25 +01: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
Andy Wingo
2263ccb53e web server: print backtrace on errors when run in batch mode
* module/web/server.scm (read-client, handle-request, write-client):
  When run in batch mode, give a full backtrace for errors.
2012-02-11 18:27:56 +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
Daniel Hartwig
0e947e1d14 permit non-date values for Expires header
* module/web/http.scm ("Expires"): Permit (some) non-date values.
2012-01-09 23:36:59 +01:00
Ian Price
ab66fb3cd1 `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.
2012-01-07 01:36:34 +01:00
Andy Wingo
eaaf94c4ec remove duplicate write-uri definition
* module/web/http.scm: Remove duplicate write-uri definition.
2012-01-07 01:26:00 +01: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
Andy Wingo
679eea4f0e allow URIs of the form file:///etc/hosts
* module/web/uri.scm (parse-authority): Allow empty authorities, so that
  we accept URIs of the form, file:///etc/hosts.
* test-suite/tests/web-uri.test ("string->uri"): Add tests.
2011-12-06 11:47:41 +01:00
Andy Wingo
fe0c202c0e Update a comment in (web client)
* module/web/client.scm: Update a comment.
2011-12-06 11:46:58 +01:00
Daniel Hartwig
69b8c5df14 fix validators for various list-style headers
* module/web/http.scm (default-val-validator): Valid with no value.
  (key-value-list?): Keys are always symbols, do not accept strings.
  (validate-param-list): Apply `valid?' to list elements.
  (validate-credentials): Validate param for Basic scheme, which
  is parsed as a string.
  (declare-symbol-list-header!): `list-of?' args were in wrong order.
  ("Cache-Control"): Replace `default-val-validator' with more
  specific procedure.
  ("Accept"): Validate on first param which has no value.
2011-11-23 23:35:20 +01:00
Andy Wingo
a24885b27d fix (web http) write-date for mondays
* module/web/http.scm (write-date): Fix bug on Mondays.  Jeez!
2011-10-17 09:52:04 +02: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
0c65f52c6d more define-syntax-rule usage
* module/ice-9/boot-9.scm:
* module/ice-9/control.scm:
* module/ice-9/futures.scm:
* module/ice-9/optargs.scm:
* module/ice-9/poll.scm:
* module/ice-9/receive.scm:
* module/ice-9/threads.scm:
* module/ice-9/vlist.scm:
* module/language/assembly/compile-bytecode.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/tree-il.scm:
* module/oop/goops.scm:
* module/oop/goops/simple.scm:
* module/oop/goops/stklos.scm:
* module/srfi/srfi-1.scm:
* module/srfi/srfi-35.scm:
* module/srfi/srfi-39.scm:
* module/srfi/srfi-45.scm:
* module/srfi/srfi-67/compare.scm:
* module/sxml/match.scm:
* module/system/repl/error-handling.scm:
* module/system/repl/repl.scm:
* module/system/vm/inspect.scm:
* module/texinfo.scm:
* module/web/server.scm: Use define-syntax-rule, where it makes sense.
2011-09-02 11:36:14 +02:00
Andy Wingo
2b582a285a (web http): locale-independent parsing and serialization of dates
* module/web/http.scm (parse-month, parse-rfc-822-date):
  (parse-rfc-850-date, parse-asctime-date, parse-date):
  (write-date): Parse and write dates without regard to the current
  locale, using a custom parser.  Also permits parsing of the deprecated
  RFC 850 and asctime() date formats.
2011-08-04 15:07:27 +02:00
Andy Wingo
072624134b open-socket-for-url returns port in latin1 encoding
* module/web/client.scm (open-socket-for-uri): Set port encoding to
  latin1, to see if this fixes Nalin Garut's problems.
2011-07-21 09:42:20 +02:00
Andy Wingo
037a680321 ensure presence of Host header in HTTP/1.1 requests
* module/web/request.scm (build-request): Make sure that HTTP/1.1
  requests have the Host header set, per RFC 2616 section 9.

* test-suite/tests/web-request.test ("example-1"): Add test.
2011-07-15 13:36:52 +02:00
Andy Wingo
680c8c5a99 add (web client)
* module/web/client.scm: New module, a simple synchronous web client.

* module/Makefile.am (WEB_SOURCES): Add to the build.
2011-07-15 13:36:47 +02:00
Andy Wingo
a964aa62c2 web server more assiduous about closing ports
* module/web/uri.scm:
* module/web/server.scm (call-with-output-string*):
  (call-with-output-bytevector*): Local procs to output to strings or
  bytevectors, *and then close the port*.  We can't make this change in
  call-with-output-string because it would be incompatible.

* module/web/uri.scm (call-with-encoded-output-string, decode-string)
  (uri-decode)
* module/web/server.scm (call-with-encoded-output-string): Use the new
  helpers.
2011-02-24 11:10:49 +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