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
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
Aleix Conchillo Flaque
6fe2803b45 web: uri-encode hexadecimal percent-encoding is now uppercase
* 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-05-02 17:13:55 -04: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
Andy Wingo
5a35d42aa5 add read-string and read-string! to (ice-9 rdelim)
* 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-22 15:15:43 +01:00
Daniel Hartwig
4e81e9d9a3 web client: correctly handle uri-query, etc. in relative URI headers
* 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.
2012-11-27 22:41:33 +01:00
Daniel Hartwig
890647559d (web uri): document that uri-port is an integer
* doc/ref/web.texi (URIs):
* module/web/uri.scm (build-uri): Document that uri-port is an integer.
2012-11-24 15:54:07 +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
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
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
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
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
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
Andy Wingo
91b320fe16 uri-encode fast path
* module/web/uri.scm (uri-encode): Add a fast-path for the common case
  in which the string does not contain any reserved characters.
2011-01-07 09:18:36 -08:00
Andy Wingo
7d6b8b75fc uri-decode #:encoding, not #:charset
* module/web/uri.scm (call-with-encoded-output-string, encode-string)
  (decode-string, uri-decode, uri-encode): Change all instances of
  "charset" to "encoding", as variables and arguments.
2011-01-07 09:18:36 -08:00
Andy Wingo
8745c33afb rename string->uri and uri->string.
* module/web/uri.scm (string->uri, uri->string): Rename from parse-uri
  and unparse-uri.

* test-suite/tests/web-uri.test:
* module/web/http.scm: All callers changed.
2011-01-07 09:18:36 -08:00
Andy Wingo
277bbe9624 document (web uri), and simplify uri-encode
* module/web/uri.scm: Add docstrings.
  (uri-encode): Simplify. Not sure what I was thinking before.
2010-12-16 14:48:34 +01:00
Andy Wingo
998191fd4f fix testing code in web/server
* module/web/server.scm (call-with-encoded-output-string): Fix some code
  I accidentally left in while testing. Re-tested the difference in
  speed; pleasantly surprised.

* module/web/uri.scm: Make the same change here.
2010-12-12 23:34:18 +01:00
Andy Wingo
c7857da63a (web uri) can uri-decode non-utf-8 payloads
* module/web/uri.scm (call-with-encoded-output-string, encode-string):
  Copy from server.scm
  (decode-string): Copy from tekuti.
  (uri-decode): The #:charset arg is a string, like
  port-encoding. Support other charsets.
  (uri-encode): Charset is a string. Other encodings still not nicely
  supported. Hmm.
2010-12-11 19:19:41 +01:00
Andy Wingo
4eb7c8f004 unparse-uri avoids serializing e.g. :80 in http:// uris
* module/web/uri.scm (declare-default-port!): New function, declares a
  default port for a scheme. Predeclare default ports for http and
  https.
  (unparse-uri): If the port is the default port for the given scheme,
  don't serialize the port part of the URI.
2010-11-12 17:16:35 +01:00
Andy Wingo
5a2f7fb315 URI parsing errors throw to `uri-error'
* module/web/uri.scm (uri-error): New proc, throws to 'uri-error.
  (validate-uri, uri-decode, uri-encode): Use uri-error.

* test-suite/tests/web-uri.test: Update for uri-error.
2010-11-04 22:52:47 +01:00
Andy Wingo
73124c6c63 web/uri: reimplement for rfc 3986, add tests
* module/web/uri.scm: Reimplement for RFC 3986.

* module/Makefile.am: Add to build.

* test-suite/Makefile.am:
* test-suite/tests/web-uri.test: Add tests.
2010-10-17 20:35:22 +02:00
Andy Wingo
15c9af8c71 import uri.scm from tekuti, from guile-www 2010-10-17 20:35:22 +02:00