-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
The documentation claims that url@
from net/url-unit
imports tcp^
, but this appears not to have been true since c69253c#diff-c932338aaf3ee8d02284a58f1e67c58a. This means you can't link against your own unit to replace the normal TCP interface, defeating most of the point of url@
.
On the one hand, the fact that no one seems to have noticed this in eight years suggests that it hasn't been a problem for existing users of url@
, and the docs do also claim that url@
"will likely be removed in the future" (though that seems very unusual for Racket). On the other hand, it doesn't seem like this was intended to be a breaking change, and the difference from the documented behavior is clear. More broadly, I don't see another equivalently-powerful way to interpose on the transport layer while re-using the HTTP implementation. (In particular, there isn't a http-client@
.)
As an example, this program should raise an exception, but instead it prints the Racket homepage:
#lang racket
(require net/url-unit
net/tcp-sig)
(define-unit custom-tcp@
(import)
(export tcp^)
(define-syntax-rule (define-got-here name ...)
(begin (define (name . args)
(error 'name "got here"))
...))
(define-got-here
tcp-listen tcp-connect tcp-connect/enable-break
tcp-accept tcp-accept/enable-break tcp-accept-ready?
tcp-close tcp-listener? tcp-abandon-port tcp-addresses))
(define-values/invoke-unit/infer
(link url@ custom-tcp@))
(displayln
(call/input-url (string->url "https://racket-lang.org")
get-pure-port
port->string))