ERROR: bad-request-line < request-error parse-error ;
: check-absolute ( url -- )
- path>> dup "/" head? [ drop ] [ invalid-path ] if ; inline
+ path>> dup "/" head? [ drop ] [ throw-invalid-path ] if ; inline
: parse-request-line-safe ( string -- triple )
- [ parse-request-line ] [ nip bad-request-line ] recover ;
+ [ parse-request-line ] [ nip throw-bad-request-line ] recover ;
: read-request-line ( request -- request )
read-?crlf [ dup "" = ] [ drop read-?crlf ] while
: parse-multipart-form-data ( string -- separator )
";" split1 nip
- "=" split1 nip [ no-boundary ] unless* ;
+ "=" split1 nip [ throw-no-boundary ] unless* ;
: maybe-limit-input ( content-length -- )
unlimited-input upload-limit get [ min ] when* limited-input ;
"content-length" header [
dup string>number [
nip dup 0 upload-limit get between? [
- invalid-content-length
+ throw-invalid-content-length
] unless
- ] [ invalid-content-length ] if*
- ] [ content-length-missing ] if* ;
+ ] [ throw-invalid-content-length ] if*
+ ] [ throw-content-length-missing ] if* ;
: parse-content ( request content-type -- post-data )
dup <post-data> -rot over parse-content-length-safe swap