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.c
- Committer:
- andrewboyson
- Date:
- 2019-03-19
- Revision:
- 131:774f7f367031
- Parent:
- 129:9c57197fb698
- Child:
- 142:a8c0890a58d1
File content as of revision 131:774f7f367031:
#include <stdbool.h> #include "http.h" #include "tcpbuf.h" #include "action.h" #include "net.h" #include "log.h" #include "led.h" #include "fault.h" bool HttpTrace = false; //Plumb into these from your html server void (*HttpRequestFunction)(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete, uint32_t* pDelayUntil); void (*HttpReplyFunction )(int todo); void HttpHandleRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete, uint32_t* pDelayUntil) { int lastFaultPoint = FaultPoint; FaultPoint = FAULT_POINT_HttpHandleRequest; if (HttpTrace) { LogF("HTTP <<< %d (%u)\r\n", size, positionInRequestStream); } HttpRequestFunction(size, pRequestStream, positionInRequestStream, pToDo, pPostComplete, pDelayUntil); FaultPoint = lastFaultPoint; } void HttpSendReply(int* pSize, char* pReplyStream, uint32_t positionInReplyStream, uint16_t mss, int todo) { TcpBufStart(positionInReplyStream, mss, pReplyStream); HttpReplyFunction(todo); *pSize = TcpBufLength(); if (HttpTrace) { LogF("HTTP >>> %d (%d)\r\n", *pSize, positionInReplyStream); } }