From 5ff179fad970eb0a878a27511d6c90419bac2cdf Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Tue, 12 Mar 2013 20:13:53 +0100 Subject: Tue Mar 12 20:13:53 CET 2013 --- picohttp.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'picohttp.h') diff --git a/picohttp.h b/picohttp.h index 47c8e6c..093cabc 100644 --- a/picohttp.h +++ b/picohttp.h @@ -18,11 +18,21 @@ #define PICOHTTP_CODING_GZIP 4 #define PICOHTTP_CODING_CHUNKED 8 +#define PICOHTTP_STATUS_200_OK 200 +#define PICOHTTP_STATUS_400_BAD_REQUEST 400 +#define PICOHTTP_STATUS_404_NOT_FOUND 404 +#define PICOHTTP_STATUS_405_METHOD_NOT_ALLOWED 405 +#define PICOHTTP_STATUS_414_REQUEST_URI_TOO_LONG 414 +#define PICOHTTP_STATUS_500_INTERNAL_SERVER_ERROR 500 +#define PICOHTTP_STATUS_501_NOT_IMPLEMENTED 501 +#define PICOHTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED 505 + struct picohttpIoOps { int (*read)(size_t /*count*/, char* /*buf*/, void*); int (*write)(size_t /*count*/, char const* /*buf*/, void*); int16_t (*getch)(void*); // returns -1 on error int (*putch)(char, void*); + int (*flush)(void*); void *data; }; @@ -30,6 +40,7 @@ struct picohttpIoOps { #define picohttpIoRead(ioops,size,buf) (ioops->read(size, buf, ioops->data)) #define picohttpIoGetch(ioops) (ioops->getch(ioops->data)) #define picohttpIoPutch(ioops,c) (ioops->putch(c, ioops->data)) +#define picohttpIoFlush(ioops) (ioops->flush(ioops->data)) enum picohttpVarType { PICOHTTP_TYPE_UNDEFINED = 0, @@ -85,7 +96,7 @@ struct picohttpRequest { size_t contentlength; uint8_t contentcoding; uint8_t te; - } queryheader; + } query; struct { char const *contenttype; char const *date; @@ -94,7 +105,7 @@ struct picohttpRequest { size_t contentlength; uint8_t contentencoding; uint8_t transferencoding; - } responseheader; + } response; struct { size_t octets; uint8_t header; -- cgit v1.2.3 From b46e67be631d5d007390c29ba89a79b02d0d984b Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Wed, 13 Mar 2013 22:22:27 +0100 Subject: Wed Mar 13 22:22:27 CET 2013 --- picohttp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'picohttp.h') diff --git a/picohttp.h b/picohttp.h index 093cabc..fba8dfa 100644 --- a/picohttp.h +++ b/picohttp.h @@ -40,7 +40,7 @@ struct picohttpIoOps { #define picohttpIoRead(ioops,size,buf) (ioops->read(size, buf, ioops->data)) #define picohttpIoGetch(ioops) (ioops->getch(ioops->data)) #define picohttpIoPutch(ioops,c) (ioops->putch(c, ioops->data)) -#define picohttpIoFlush(ioops) (ioops->flush(ioops->data)) +#define picohttpIoFlush(ioops) (ioops->flush(ioops->data)) enum picohttpVarType { PICOHTTP_TYPE_UNDEFINED = 0, -- cgit v1.2.3 From f713f27297f04981054937f295a895edaab594cb Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Wed, 13 Mar 2013 22:24:28 +0100 Subject: Wed Mar 13 22:24:28 CET 2013 --- picohttp.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'picohttp.h') diff --git a/picohttp.h b/picohttp.h index 093cabc..66317b1 100644 --- a/picohttp.h +++ b/picohttp.h @@ -2,7 +2,7 @@ #ifndef PICOHTTP_H_HEADERGUARD #define PICOHTTP_H_HEADERGUARD -#include +#include #include #define PICOHTTP_MAJORVERSION(x) ( (x & 0x7f00) >> 8 ) @@ -83,8 +83,8 @@ struct picohttpRequest { struct picohttpIoOps const * ioops; struct picohttpURLRoute const * route; struct picohttpVar *get_vars; - char const *url; - char const *urltail; + char *url; + char *urltail; int16_t status; int16_t method; struct { @@ -116,6 +116,9 @@ void picohttpProcessRequest( struct picohttpIoOps const * const ioops, struct picohttpURLRoute const * const routes ); +void picohttpStatusResponse( + struct picohttpRequest *req, int16_t status ); + int picohttpResponseSendHeader ( struct picohttpRequest * const req ); -- cgit v1.2.3