support \n line endings on http head
This commit is contained in:
parent
a9894d8a03
commit
c9463c6938
1 changed files with 12 additions and 4 deletions
|
@ -51,17 +51,25 @@ construct net:http:server:Request {
|
||||||
def buf 1024 anew =buf
|
def buf 1024 anew =buf
|
||||||
def found
|
def found
|
||||||
while {
|
while {
|
||||||
buf this:stream:read pop =read
|
buf this:stream:read pop dup =read
|
||||||
"\r\n\r\n" :to-bytes buf:find dup =found not read and
|
"\r\n\r\n" :to-bytes buf:find dup =found null eq and
|
||||||
} {
|
} {
|
||||||
this:head buf:sub<0 read> aadd this:=head
|
this:head buf:sub<0 read>:replace<"\r" :to-bytes 0 anew> aadd this:=head
|
||||||
|
"\n\n" :to-bytes this:head:find dup null eq not if {
|
||||||
|
=found
|
||||||
|
this:head:sub<0 found>:to-str this:=head
|
||||||
|
1 ( buf:0 "\r" eq if { pop 2 } ) buf:len buf:sub =buf
|
||||||
|
buf this:=body
|
||||||
|
this
|
||||||
|
4 stop
|
||||||
|
0 } pop
|
||||||
}
|
}
|
||||||
this:head buf:sub<0 found> aadd:to-str this:=head
|
this:head buf:sub<0 found> aadd:to-str this:=head
|
||||||
buf:sub<found 4 + buf:len> this:=body
|
buf:sub<found 4 + buf:len> this:=body
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
parse-head { this | with this ;
|
parse-head { this | with this ;
|
||||||
this:head:split<"\r\n"> this:=head
|
this:head:split<"\n"> this:=head
|
||||||
def iter this:head:iter =iter
|
def iter this:head:iter =iter
|
||||||
iter:next:readf<"{} {} HTTP/{}"> dup if {
|
iter:next:readf<"{} {} HTTP/{}"> dup if {
|
||||||
dup:to-stack this:=version this:=raw-path this:=method
|
dup:to-stack this:=version this:=raw-path this:=method
|
||||||
|
|
Loading…
Add table
Reference in a new issue