From f8784d25aa8894e900451148094777ace25ab708 Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Thu, 25 Jul 2013 14:40:07 +0200 Subject: NULL contanttype response now permitted --- picohttp.c | 20 +++++++++++--------- test/bsdsocket.c | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/picohttp.c b/picohttp.c index 6ecc528..9986788 100644 --- a/picohttp.c +++ b/picohttp.c @@ -1039,15 +1039,17 @@ int picohttpResponseSendHeaders ( 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR_CRLF)) ) return e; - /* Content-Type header */ - if( 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR_CONTENT)) || - 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR__TYPE)) || - 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR_CLSP)) || - 0 > (e = picohttpIoWrite( - req->ioops, strlen(req->response.contenttype), - req->response.contenttype)) || - 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR_CRLF)) ) - return e; + if(req->response.contenttype) { + /* Content-Type header */ + if( 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR_CONTENT)) || + 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR__TYPE)) || + 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR_CLSP)) || + 0 > (e = picohttpIoWrite( + req->ioops, strlen(req->response.contenttype), + req->response.contenttype)) || + 0 > (e = picohttpIO_WRITE_STATIC_STR(PICOHTTP_STR_CRLF)) ) + return e; + } /* Content-Length header */ if( req->response.contentlength ){ diff --git a/test/bsdsocket.c b/test/bsdsocket.c index 5350db9..d33e5f7 100644 --- a/test/bsdsocket.c +++ b/test/bsdsocket.c @@ -113,6 +113,8 @@ void rhRoot(struct picohttpRequest *req) "
\n" "
\n" "
\n" +"
\n" +"
\n" "\n" "\n" "\n"; -- cgit v1.2.3