Search
Wednesday, 23rd of June 2021, 16:05:49 UTC
17:32:07
bpanthi977
patience_: (setf ,',sym ,y) try this
21:40:38
erik_
specbot, clhs load-time-value
21:40:56
erik_
apparently, that's not how it works.
21:41:38
Colleen
Clhs: special operator load-time-value http://www.lispworks.com/documentation/HyperSpec/Body/s_ld_tim.htm
22:21:37
char
what is consensus on using guix to manage common lisp packages?
0:50:01
ivche
hey ppl, so im going through some material, and im trying to make a web server as an exercise
0:50:24
ivche
i use sbcl and the resource uses clisp, so socket implementation is different
0:50:46
ivche
therefore I cant see where I'm making a mistake
0:51:02
ivche
https://ghostbin.co/paste/nezu
0:51:40
ivche
here is my code, when I start up the server with the (serve) function, and try to visit the server from my browser
0:52:45
ivche
#<SB-SYS:FD-STREAM for "socket 127.0.0.1:8820, peer: 127.0.0.1:39478" {100288D503}>:
0:52:45
ivche
the octet sequence #(252 3 3 43) cannot be decoded.
0:52:48
ivche
[Condition of type SB-INT:STREAM-DECODING-ERROR]
0:53:02
ivche
any ideas why that might be the case?
0:55:00
kakuhen
depending on what exactly the clisp resource uses, you may be able to get away with using usocket
0:55:17
kakuhen
it should give you the relevant sbcl socket calls when using it
0:56:13
kakuhen
anyway, assuming your serve function is set up correctly, can you trace the function that gets given that octet sequence
1:03:04
pjb
ivche: you don't specify an :element-type to sockets, so it's character by default, therefore it uses an encoding. Since you didn't specify a common :external-format, it's the default one in each process that is used. Probably not the same.
1:04:13
pjb
ivche: https://koji-kojiro.github.io/sb-docs/build/html/sb-bsd-sockets/generic-function/SOCKET-MAKE-STREAM.html
1:04:27
pjb
Try :element-type '(unsigned-byte 8)
1:04:48
ivche
CL-USER> sb-ext:*default-external-format*
1:05:07
pjb
How do you know the other process uses utf-8 too?
1:05:46
ivche
The default external format is UTF-8. It can be changed via
1:05:47
ivche
sb-ext:*default-external-format* and sb-ext:*default-c-string-external-format*
1:06:16
pjb
ivche: also, 3 is not the ASCII code of a character, but an ASCII control code (for ETX). So it's not a character stream.
1:06:24
ivche
i think i accessed it via https
1:06:32
ivche
and that messed it up
1:06:55
pjb
Then you'd have to use a TLS library.
1:07:15
pjb
ivche: you can try: telnet 127.0.0.1 8820
1:07:18
ivche
but when i tried http, i get localhost sent an invalid response
1:07:33
ivche
and when i tried to curl it, i got
1:07:40
pjb
Does your exercise involves TLS?
1:07:49
ivche
* Connected to localhost (127.0.0.1) port 8822 (#0)
1:07:49
ivche
> GET /greeting HTTP/1.1
1:07:49
ivche
> Host: localhost:8822
1:07:49
ivche
> User-Agent: curl/7.77.0
1:08:00
ivche
* Received HTTP/0.9 when not allowed
1:08:03
ivche
* Closing connection 0
1:08:27
ivche
why cant i GET it tho?
1:09:31
ivche
Connected to 127.0.0.1.
1:09:32
ivche
Escape character is '^]'.
1:09:39
ivche
this is the telnet output
1:09:45
pjb
GET /greeting HTTP/1.1 RET
1:11:05
ivche
Connected to 127.0.0.1.
1:11:05
ivche
Escape character is '^]'.
1:11:05
ivche
GET /greeting HTTP/1.1 RET
1:11:11
ivche
Sorry... I don't know that page.Connection closed by foreign host.
1:11:11
pjb
Are you witting a server or a client?
1:11:17
ivche
omg i actually got a response
1:11:35
pjb
But it is not correct, it should start with a http status code!
1:12:01
ivche
no but it's a mock server
1:12:17
ivche
it doesn't implement all of http
1:13:09
ivche
why can't i access it from the browser tho
1:13:20
pjb
Anyways, contrarily to the appearances, HTTP is a binary protocol…
1:13:43
pjb
ivche: because you didn't implement HTTP, only a mock version of it.
1:14:21
ivche
yeah but the guy in the book gets a response
1:14:41
pjb
perhaps he doesn't use the same browser?
1:14:42
ivche
can it be that the book is ancient?
1:24:34
pjb
ivche: it could help if you flushed the buffers!
1:25:27
ivche
it actually works on firefox
1:27:10
ivche
i was saying, firefox works
1:29:09
ivche
but why does it display this <!DOCTYPE html><html><meta charset="utf-8"><h1>Hello world!</h1></html>
1:29:15
ivche
instead rendering the HTML?
1:29:38
pjb
Because you didn't return a HTTP header with the content-type.
1:31:00
pjb
https://www.w3.org/Protocols/
1:31:44
ivche
yeah, a lot has changed
1:31:56
pjb
See the example in section 2.1 in https://datatracker.ietf.org/doc/html/rfc7230
1:45:45
ivche
https://imgur.com/wQEpxmk
1:46:02
ivche
thank you a lot.. With the headers, it works on chrome too
1:46:22
ivche
but that's chrome anyways :D
3:02:20
beach
Good morning everyone!
3:39:39
Lord_of_Life_
** NICK Lord_of_Life
Thursday, 24th of June 2021, 4:05:49 UTC