Skip to content

Commit

Permalink
http.server: closing socket without sending any text would hang the h…
Browse files Browse the repository at this point in the history
…ttp.server. Fixes factor#311
  • Loading branch information
slavapestov committed Oct 29, 2011
1 parent fd944c5 commit b740d79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions basis/http/http-tests.factor
Expand Up @@ -456,3 +456,14 @@ SYMBOL: a
[ "OK\n\n" ] [ "http://localhost/" add-addr http-get nip ] unit-test [ "OK\n\n" ] [ "http://localhost/" add-addr http-get nip ] unit-test


[ ] [ stop-test-httpd ] unit-test [ ] [ stop-test-httpd ] unit-test

! Check that just closing the socket without sending anything works
[ ] [
<dispatcher>
add-quit-action
test-httpd
] unit-test

[ ] [ "addr" get binary [ ] with-client ] unit-test

[ ] [ stop-test-httpd ] unit-test
2 changes: 1 addition & 1 deletion basis/http/server/server.factor
Expand Up @@ -37,7 +37,7 @@ IN: http.server
dup path>> "/" head? [ "Bad request: URL" throw ] unless ; inline dup path>> "/" head? [ "Bad request: URL" throw ] unless ; inline


: read-request-line ( request -- request ) : read-request-line ( request -- request )
read-?crlf [ dup empty? ] [ drop read-?crlf ] while read-?crlf [ dup "" = ] [ drop read-?crlf ] while
parse-request-line first3 parse-request-line first3
[ >>method ] [ >url check-absolute >>url ] [ >>version ] tri* ; [ >>method ] [ >url check-absolute >>url ] [ >>version ] tri* ;


Expand Down

0 comments on commit b740d79

Please sign in to comment.