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.cpp
- Committer:
- andrewboyson
- Date:
- 2017-11-13
- Revision:
- 54:84ef2b29cf7e
- Child:
- 55:e64b8b47a2b6
File content as of revision 54:84ef2b29cf7e:
#include "mbed.h" #include "http.h" #include "tcpbuf.h" #include "action.h" #include "net.h" #include "log.h" bool HttpTrace = false; void (*HttpReplyFunction )(int todo); //Plumb into this from your html server int (*HttpRequestFunction)(char *pPath, char *pLastModified, char *pQuery); //Plumb into this from your html server int HttpHandleRequest(void (*traceback)(void), int* pSize, char* pRequestStream, int positionInRequestStream, char* pReplyStream, int positionInReplyStream, uint16_t mss, int* pToDo) { if (HttpTrace) { if (NetTraceNewLine) Log("\r\n"); LogTimeF("HTTP packet received starting at %d length %d bytes\r\n", positionInRequestStream, *pSize); } //Handle request for the first packet of data received but leave todo the same after that. if (*pSize) { char* pMethod; char* pPath; char* pQuery; char* pLastModified; HttpReadRequest(pRequestStream, *pSize, &pMethod, &pPath, &pQuery, &pLastModified); *pToDo = HttpRequestFunction(pPath, pLastModified, pQuery); } //Handle sending of any data TcpBufStart(positionInReplyStream, mss, pReplyStream); HttpReplyFunction(*pToDo); *pSize = TcpBufLength(); return UNICAST; }