aboutsummaryrefslogtreecommitdiff
path: root/picohttp.h
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-03-14 12:11:19 +0100
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2013-03-14 12:11:19 +0100
commit15fdfef7f3556e681ab0ca69ad603cac30eb2008 (patch)
tree889d649a53e2a999a289a60c92a7ef179e1c11c4 /picohttp.h
parentdb106357956d84283dc85ea3e47d512da5113db3 (diff)
parent695008f9d18220e9d9c2558129ffcd4db15d2a26 (diff)
downloadlitheweb-15fdfef7f3556e681ab0ca69ad603cac30eb2008.tar.gz
litheweb-15fdfef7f3556e681ab0ca69ad603cac30eb2008.tar.bz2
Merge branch 'master' of github.com:datenwolf/picoweb
Diffstat (limited to 'picohttp.h')
-rw-r--r--picohttp.h24
1 files changed, 19 insertions, 5 deletions
diff --git a/picohttp.h b/picohttp.h
index 47c8e6c..041f124 100644
--- a/picohttp.h
+++ b/picohttp.h
@@ -2,7 +2,7 @@
#ifndef PICOHTTP_H_HEADERGUARD
#define PICOHTTP_H_HEADERGUARD
-#include <stdlib.h>
+#include <stddef.h>
#include <stdint.h>
#define PICOHTTP_MAJORVERSION(x) ( (x & 0x7f00) >> 8 )
@@ -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,
@@ -72,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 {
@@ -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;
@@ -105,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 );