Andrew Boyson / net

Dependents:   oldheating gps motorhome heating

Committer:
andrewboyson
Date:
Sun Sep 01 18:14:13 2019 +0000
Revision:
157:b0bdb77e27f3
Parent:
156:be12b8fd5b21
Child:
158:3adf725c0804
Tidied parameter order in HttpShim

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 146:0fc66d610fd6 1 #include <stdbool.h>
andrewboyson 146:0fc66d610fd6 2
andrewboyson 146:0fc66d610fd6 3 #include "http.h"
andrewboyson 146:0fc66d610fd6 4 #include "tcp.h"
andrewboyson 146:0fc66d610fd6 5 #include "tcpbuf.h"
andrewboyson 146:0fc66d610fd6 6 #include "tls.h"
andrewboyson 146:0fc66d610fd6 7
andrewboyson 146:0fc66d610fd6 8 /*
andrewboyson 146:0fc66d610fd6 9 The shim acts as the switch between TCP, TLS and HTTP.
andrewboyson 146:0fc66d610fd6 10 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.
andrewboyson 146:0fc66d610fd6 11 It means TCP does not need to know if it is talking directly to HTTP or via TLS.
andrewboyson 146:0fc66d610fd6 12 */
andrewboyson 157:b0bdb77e27f3 13 void HttpShimReset(bool secure, int connection)
andrewboyson 146:0fc66d610fd6 14 {
andrewboyson 156:be12b8fd5b21 15 if (secure) TlsReset(connection); //Only reset TLS if appropriate
andrewboyson 156:be12b8fd5b21 16 HttpFunctionReset(connection); //Always reset Http
andrewboyson 156:be12b8fd5b21 17 }
andrewboyson 157:b0bdb77e27f3 18 void HttpShimRequest(bool secure, int connection, int size, char* pRequestStream, uint32_t positionInRequestStream)
andrewboyson 156:be12b8fd5b21 19 {
andrewboyson 156:be12b8fd5b21 20 if (secure) TlsRequest (connection, size, (uint8_t*)pRequestStream, positionInRequestStream);
andrewboyson 156:be12b8fd5b21 21 else HttpFunctionRequest(connection, size, pRequestStream, positionInRequestStream);
andrewboyson 146:0fc66d610fd6 22 }
andrewboyson 146:0fc66d610fd6 23
andrewboyson 146:0fc66d610fd6 24 static bool tlsRequired;
andrewboyson 157:b0bdb77e27f3 25 bool HttpShimPoll (bool secure, int connection, bool clientFinished)
andrewboyson 146:0fc66d610fd6 26 {
andrewboyson 146:0fc66d610fd6 27 tlsRequired = secure;
andrewboyson 156:be12b8fd5b21 28 if (tlsRequired) return TlsPoll (connection, clientFinished);
andrewboyson 156:be12b8fd5b21 29 else return HttpFunctionPoll(connection, clientFinished);
andrewboyson 147:a6093b52e654 30 }
andrewboyson 155:22f249751106 31 void HttpShimAddChar(char c)
andrewboyson 146:0fc66d610fd6 32 {
andrewboyson 146:0fc66d610fd6 33 if (tlsRequired) TlsAddChar(c);
andrewboyson 146:0fc66d610fd6 34 else TcpBufAddChar(c);
andrewboyson 146:0fc66d610fd6 35 }
andrewboyson 146:0fc66d610fd6 36
andrewboyson 146:0fc66d610fd6 37 bool HttpShimBufFilled()
andrewboyson 146:0fc66d610fd6 38 {
andrewboyson 146:0fc66d610fd6 39 return TcpBufFilled();
andrewboyson 146:0fc66d610fd6 40 }
andrewboyson 157:b0bdb77e27f3 41 bool HttpShimGetTrace(bool secure)
andrewboyson 146:0fc66d610fd6 42 {
andrewboyson 157:b0bdb77e27f3 43 if (secure) return HttpTrace || TlsTrace;
andrewboyson 157:b0bdb77e27f3 44 else return HttpTrace;
andrewboyson 146:0fc66d610fd6 45 }