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
Diff: tcp/http/httpshim.c
- Revision:
- 145:206bf0d073c7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tcp/http/httpshim.c Tue May 14 15:09:39 2019 +0000 @@ -0,0 +1,39 @@ +#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); +} \ No newline at end of file