Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
tcp/http/httpshim/httpshim.c@155:22f249751106, 2019-08-20 (annotated)
- Committer:
- andrewboyson
- Date:
- Tue Aug 20 14:49:00 2019 +0000
- Revision:
- 155:22f249751106
- Parent:
- 154:ba9879b19d9f
- Child:
- 156:be12b8fd5b21
Changed TcpBuf bytes from char to uint8_t
Who changed what in which revision?
| User | Revision | Line number | New 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 | 146:0fc66d610fd6 | 13 | |
| andrewboyson | 147:a6093b52e654 | 14 | void HttpShimRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pWebState, char* pTlsState, bool secure) |
| andrewboyson | 146:0fc66d610fd6 | 15 | { |
| andrewboyson | 155:22f249751106 | 16 | if (secure) TlsRequest (pTlsState, pWebState, size, (uint8_t*)pRequestStream, positionInRequestStream); |
| andrewboyson | 155:22f249751106 | 17 | else HttpRequestFunction( pWebState, size, pRequestStream, positionInRequestStream); |
| andrewboyson | 146:0fc66d610fd6 | 18 | } |
| andrewboyson | 146:0fc66d610fd6 | 19 | |
| andrewboyson | 146:0fc66d610fd6 | 20 | static bool tlsRequired; |
| andrewboyson | 147:a6093b52e654 | 21 | int HttpShimPoll (bool clientFinished, char* pWebState, char* pTlsState, bool secure) |
| andrewboyson | 146:0fc66d610fd6 | 22 | { |
| andrewboyson | 146:0fc66d610fd6 | 23 | tlsRequired = secure; |
| andrewboyson | 147:a6093b52e654 | 24 | if (tlsRequired) return TlsPoll (pTlsState, pWebState, clientFinished); |
| andrewboyson | 147:a6093b52e654 | 25 | else return HttpPollFunction( pWebState, clientFinished); |
| andrewboyson | 147:a6093b52e654 | 26 | } |
| andrewboyson | 155:22f249751106 | 27 | void HttpShimAddChar(char c) |
| andrewboyson | 146:0fc66d610fd6 | 28 | { |
| andrewboyson | 146:0fc66d610fd6 | 29 | if (tlsRequired) TlsAddChar(c); |
| andrewboyson | 146:0fc66d610fd6 | 30 | else TcpBufAddChar(c); |
| andrewboyson | 146:0fc66d610fd6 | 31 | } |
| andrewboyson | 146:0fc66d610fd6 | 32 | |
| andrewboyson | 146:0fc66d610fd6 | 33 | bool HttpShimBufFilled() |
| andrewboyson | 146:0fc66d610fd6 | 34 | { |
| andrewboyson | 146:0fc66d610fd6 | 35 | return TcpBufFilled(); |
| andrewboyson | 146:0fc66d610fd6 | 36 | } |
| andrewboyson | 146:0fc66d610fd6 | 37 | bool HttpShimGetTrace() |
| andrewboyson | 146:0fc66d610fd6 | 38 | { |
| andrewboyson | 155:22f249751106 | 39 | if (tlsRequired) return TlsTrace; |
| andrewboyson | 155:22f249751106 | 40 | else return HttpTrace; |
| andrewboyson | 146:0fc66d610fd6 | 41 | } |