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/httpshim.c
- Committer:
- andrewboyson
- Date:
- 2019-05-14
- Revision:
- 145:206bf0d073c7
File content as of revision 145:206bf0d073c7:
#include <stdbool.h> #include "tcp.h" #include "tcpbuf.h" #include "tls.h" //Plumb into these from your html server void (*HttpRequestFunction)(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pState); bool (*HttpReplyPollFunction)(char* pState, bool clientFinished); void HttpRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pState) { HttpRequestFunction(size, pRequestStream, positionInRequestStream, pState); } void HttpsRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pState) { TlsRequest (size, pRequestStream, positionInRequestStream, pState); } bool HttpBufFilled(void) { return TcpBufFilled(); } static bool tlsRequired; bool HttpReplyPoll (char* pState, bool clientFinished) { tlsRequired = false; return HttpReplyPollFunction(pState, clientFinished); } bool HttpsReplyPoll(char* pState, bool clientFinished) { tlsRequired = true; return TlsReplyPoll(pState, clientFinished); } void HttpAddChar (char c) { if (tlsRequired) TlsAddChar(c); else TcpBufAddChar(c); }