[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MIT-Scheme-devel] http-client broken

From: Chris Hanson
Subject: Re: [MIT-Scheme-devel] http-client broken
Date: Thu, 23 Nov 2017 17:12:30 -0800

It's a little complicated.

The HTTP I/O needs to switch between textual and binary, because the envelope of an HTTP message is textual while the body of the message is binary. Since this was designed before we implemented bytevectors and binary ports, the only option was to use textual ports and switch their encoding -- and use strings to represent binary data.

The current situation is different. One possible approach would be to wrap a binary socket port in a textual port, use the textual port to generate the envelope, then use the wrapped binary port to handle the body. This would require synchronizing the textual port at appropriate times, but would have the advantage of being pretty straightforward.

Another possibility would be to create the header as a string, then convert it to a bytevector and write the bytevector to the socket port. Reading would be a little more complex since it would be necessary to read bytes, looking for the \r\n\r\n marker that is the end of the header, then translate the header bytes to a string and parse that. I like this a bit better, since it doesn't assume that a textual port has a binary port behind it, which is not part of R7RS. For that reason alone I prefer this approach.

In either case I think it's correct that sockets should be binary ports.

On Mon, Nov 20, 2017 at 4:41 AM, Peter <address@hidden> wrote:
Hello fellow Schemers!

I've looked into this, the problem seems to be that `socket-port-type'
in socket.scm calls make-textual-port-type, when a network socket should
in fact probably be a binary port.

If anyone could give me any pointers on how this should be fixed, I'd
like to give it a go and send a patch. Is it in fact correct to make tcp
sockets binary ports?

Thanks for any assistance!

MIT-Scheme-devel mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]