Permalink
Browse files

Better reaction on more than 3 message parts from backend (fixes #27)

Requires latest version of libwebsite from git master
  • Loading branch information...
1 parent cae0522 commit 942100b2fe5ebf57a908171c071f7bd343106c5c @tailhook committed Feb 10, 2014
Showing with 16 additions and 0 deletions.
  1. +3 −0 src/http.c
  2. +13 −0 test/simple.py
View
3 src/http.c
@@ -114,6 +114,9 @@ void http_process(struct ev_loop *loop, struct ev_io *watch, int revents) {
Z_RECV(msg);
if(msg_opt) {
TWARN("Too many message parts");
+ /* We already set status and headers,
+ * but they were only buffered, so we're lucky */
+ SNIMPL(ws_reset_headers(&req->ws));
http_static_response(req,
&REQRCONFIG(req)->responses.internal_error);
request_finish(req);
View
13 test/simple.py
@@ -120,6 +120,19 @@ def testEcho(self):
self.assertEqual(resp.headers['Content-Type'], None)
self.assertTrue(resp.headers['Date'])
+ def testBadReply(self):
+ conn = self.http()
+ self.addCleanup(conn.close)
+ conn.request('GET', '/echo/test')
+ self.assertEqual(self.backend_recv(),
+ [b'/echo/test', b''])
+ self.backend_send(b'200 OK', b'', b'hello', b'CRAP')
+ resp = conn.getresponse()
+ self.assertEqual(500, resp.status)
+ self.assertTrue(b'Error' in resp.read())
+ self.assertEqual(resp.headers['Content-Type'], None)
+ self.assertTrue(resp.headers['Date'])
+
def testHeadersEcho(self):
conn = self.http()
self.addCleanup(conn.close)

0 comments on commit 942100b

Please sign in to comment.