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

Revision:
146:0fc66d610fd6
Child:
147:a6093b52e654
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tcp/http/httpshim/httpshim.c	Wed May 15 15:33:15 2019 +0000
@@ -0,0 +1,40 @@
+#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* pState, bool secure)
+{
+    if (secure) TlsRequest         (size, pRequestStream, positionInRequestStream, pState);
+    else        HttpRequestFunction(size, pRequestStream, positionInRequestStream, pState);
+}
+
+static bool tlsRequired;
+bool HttpShimReplyPoll (char* pState, bool clientFinished, bool secure)
+{
+    tlsRequired = secure;
+    if (secure) return TlsReplyPoll         (pState, clientFinished);
+    else        return HttpReplyPollFunction(pState, clientFinished);
+}
+void HttpShimAddChar  (char c)
+{
+    if (tlsRequired) TlsAddChar(c);
+    else          TcpBufAddChar(c);
+}
+
+bool HttpShimBufFilled()
+{
+    return TcpBufFilled();
+}
+bool HttpShimGetTrace()
+{
+    return HttpTrace;
+}
\ No newline at end of file