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/httpshim.c
- Committer:
- andrewboyson
- Date:
- 2019-05-17
- Revision:
- 147:a6093b52e654
- Parent:
- 146:0fc66d610fd6
- Child:
- 154:ba9879b19d9f
File content as of revision 147:a6093b52e654:
#include <stdbool.h> #include "http.h" #include "tcp.h" #include "tcpbuf.h" #include "tls.h" /* The shim acts as the switch between TCP, TLS and HTTP. It means HTTP does not need to know if it is talking directly to TCP as HTTP or via TLS in the form of HTTPS. It means TCP does not need to know if it is talking directly to HTTP or via TLS. */ void HttpShimRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pWebState, char* pTlsState, bool secure) { if (secure) TlsRequest (pTlsState, pWebState, size, pRequestStream, positionInRequestStream); else HttpRequestFunction( pWebState, size, pRequestStream, positionInRequestStream); } static bool tlsRequired; int HttpShimPoll (bool clientFinished, char* pWebState, char* pTlsState, bool secure) { tlsRequired = secure; if (tlsRequired) return TlsPoll (pTlsState, pWebState, clientFinished); else return HttpPollFunction( pWebState, clientFinished); } bool HttpShimReply(char* pWebState, char* pTlsState) { if (tlsRequired) return TlsReply (pTlsState, pWebState); else return HttpReplyFunction( pWebState); } void HttpShimAddChar (char c) { if (tlsRequired) TlsAddChar(c); else TcpBufAddChar(c); } bool HttpShimBufFilled() { return TcpBufFilled(); } bool HttpShimGetTrace() { return HttpTrace; }