A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.

Dependents:   oldheating gps motorhome heating

tcp/http/http.h

Committer:
andrewboyson
Date:
2019-03-08
Revision:
127:fcdfbfad8770
Parent:
126:62edacc9f14d
Child:
129:9c57197fb698

File content as of revision 127:fcdfbfad8770:

#include <stdbool.h>
#include <stdarg.h>
#include <stdint.h>
#include <time.h>

extern void   HttpAddChar       (char c);
extern void   HttpFillChar      (char c, int length);
extern int    HttpAddText       (const char* text);
extern int    HttpAddV          (char *fmt, va_list argptr);
extern int    HttpAddF          (char *fmt, ...);
extern void   HttpAddData       (const char* data, int length);
extern void   HttpAddStream     (void (*startFunction)(void), int (*enumerateFunction)(void));
extern void   HttpAddNibbleAsHex(int value);
extern void   HttpAddInt12AsHex (int value);
extern void   HttpAddInt16AsHex (int value);
extern void   HttpAddTm         (struct tm* ptm);

extern int    HttpRequestRead  (char *p, int len, char** ppMethod, char** ppPath, char** ppQuery, char** ppLastModified, int* pContentLength);

extern char*  HttpQuerySplit   (char* pQuery, char** ppName, char** ppValue);
extern void   HttpQueryUnencode(char* pValue);

extern int  (*HttpRequestFunction)(char *pPath, char* pLastModified);
extern void (*HttpGetFunction    )(int todo, char *pQuery);
extern bool (*HttpPostFunction   )(int todo, int contentLength, int contentStart, int size, char* pRequestStream, uint32_t positionInRequestStream);
extern void (*HttpReplyFunction  )(int todo);

extern bool   HttpTrace;
extern void   HttpHandleRequest(int   size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete);
extern void   HttpSendReply    (int* pSize, char* pReplyStream,   uint32_t positionInReplyStream, uint16_t mss, int todo);

extern void   HttpDateFromDateTime(const char* date, const char *ptime, char* ptext);
extern void   HttpDateFromNow(char* pText);

extern bool HttpSameStr               (const char* pa,   const char* pb);
extern bool HttpSameStrCaseInsensitive(const char* pa,   const char* pb);
extern bool HttpSameDate              (const char* date, const char* time, const char* pOtherDate);

#define HTTP_DATE_LENGTH 30