mirror of https://github.com/omar-polo/gmid.git
handle CGI scripts that replies with the maximum header length allowed
the 1024 bytes limits is for the META only, not for the whole response. That means that the maximum size for the header line is 1029!
This commit is contained in:
parent
071dce449d
commit
c836cdfadb
|
@ -1,3 +1,7 @@
|
|||
2021-03-27 Omar Polo <op@omarpolo.com>
|
||||
|
||||
* gmid.h (struct client): correctly handle CGI scripts that replies with the maximum header length allowed
|
||||
|
||||
2021-03-20 Omar Polo <op@omarpolo.com>
|
||||
|
||||
* 1.6 tagged
|
||||
|
|
5
gmid.h
5
gmid.h
|
@ -180,8 +180,11 @@ struct client {
|
|||
const char *meta;
|
||||
int fd, pfd;
|
||||
DIR *dir;
|
||||
char sbuf[1024];
|
||||
|
||||
/* big enough to store STATUS + SPACE + META + CRLF */
|
||||
char sbuf[1029];
|
||||
ssize_t len, off;
|
||||
|
||||
struct sockaddr_storage addr;
|
||||
struct vhost *host; /* host they're talking to */
|
||||
};
|
||||
|
|
|
@ -68,6 +68,7 @@ testdata: fill-file
|
|||
printf "# hello world\n" > testdata/index.gmi
|
||||
./sha testdata/index.gmi testdata/index.gmi.sha
|
||||
cp hello slow err invalid serve-bigfile env testdata/
|
||||
cp max-length-reply testdata
|
||||
mkdir testdata/dir
|
||||
cp hello testdata/dir
|
||||
cp testdata/index.gmi testdata/dir/foo.gmi
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
printf '20 iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\r\n'
|
|
@ -183,6 +183,9 @@ echo OK GET /err with cgi
|
|||
eq "$(raw /invalid | wc -c | xargs)" 2048 "Unexpected body for /invalid"
|
||||
echo OK GET /invalid with cgi
|
||||
|
||||
eq "$(raw /max-length-reply | wc -c | xargs)" 1029 "Unexpected header for /max-length-reply"
|
||||
echo OK GET /max-length-reply with cgi
|
||||
|
||||
# try a big file
|
||||
eq "$(head /serve-bigfile)" "20 application/octet-stream" "Unexpected head for /serve-bigfile"
|
||||
get /bigfile > bigfile
|
||||
|
|
Loading…
Reference in New Issue