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/http.c@131:774f7f367031, 2019-03-19 (annotated)
- Committer:
- andrewboyson
- Date:
- Tue Mar 19 12:12:26 2019 +0000
- Revision:
- 131:774f7f367031
- Parent:
- 129:9c57197fb698
- Child:
- 142:a8c0890a58d1
Include ability to set a delay to a reply via TCP.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 61:aad055f1b0d1 | 1 | #include <stdbool.h> |
andrewboyson | 61:aad055f1b0d1 | 2 | |
andrewboyson | 54:84ef2b29cf7e | 3 | #include "http.h" |
andrewboyson | 54:84ef2b29cf7e | 4 | #include "tcpbuf.h" |
andrewboyson | 54:84ef2b29cf7e | 5 | #include "action.h" |
andrewboyson | 54:84ef2b29cf7e | 6 | #include "net.h" |
andrewboyson | 54:84ef2b29cf7e | 7 | #include "log.h" |
andrewboyson | 75:603b10404183 | 8 | #include "led.h" |
andrewboyson | 98:b977424ec7f7 | 9 | #include "fault.h" |
andrewboyson | 54:84ef2b29cf7e | 10 | |
andrewboyson | 54:84ef2b29cf7e | 11 | bool HttpTrace = false; |
andrewboyson | 54:84ef2b29cf7e | 12 | |
andrewboyson | 126:62edacc9f14d | 13 | //Plumb into these from your html server |
andrewboyson | 131:774f7f367031 | 14 | void (*HttpRequestFunction)(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete, uint32_t* pDelayUntil); |
andrewboyson | 126:62edacc9f14d | 15 | void (*HttpReplyFunction )(int todo); |
andrewboyson | 54:84ef2b29cf7e | 16 | |
andrewboyson | 131:774f7f367031 | 17 | void HttpHandleRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, int* pToDo, bool* pPostComplete, uint32_t* pDelayUntil) |
andrewboyson | 54:84ef2b29cf7e | 18 | { |
andrewboyson | 98:b977424ec7f7 | 19 | int lastFaultPoint = FaultPoint; |
andrewboyson | 98:b977424ec7f7 | 20 | FaultPoint = FAULT_POINT_HttpHandleRequest; |
andrewboyson | 98:b977424ec7f7 | 21 | |
andrewboyson | 54:84ef2b29cf7e | 22 | if (HttpTrace) |
andrewboyson | 54:84ef2b29cf7e | 23 | { |
andrewboyson | 79:f50e02fb5c94 | 24 | LogF("HTTP <<< %d (%u)\r\n", size, positionInRequestStream); |
andrewboyson | 54:84ef2b29cf7e | 25 | } |
andrewboyson | 126:62edacc9f14d | 26 | |
andrewboyson | 131:774f7f367031 | 27 | HttpRequestFunction(size, pRequestStream, positionInRequestStream, pToDo, pPostComplete, pDelayUntil); |
andrewboyson | 126:62edacc9f14d | 28 | |
andrewboyson | 98:b977424ec7f7 | 29 | FaultPoint = lastFaultPoint; |
andrewboyson | 71:736a5747ade1 | 30 | } |
andrewboyson | 79:f50e02fb5c94 | 31 | void HttpSendReply(int* pSize, char* pReplyStream, uint32_t positionInReplyStream, uint16_t mss, int todo) |
andrewboyson | 71:736a5747ade1 | 32 | { |
andrewboyson | 54:84ef2b29cf7e | 33 | TcpBufStart(positionInReplyStream, mss, pReplyStream); |
andrewboyson | 71:736a5747ade1 | 34 | HttpReplyFunction(todo); |
andrewboyson | 54:84ef2b29cf7e | 35 | *pSize = TcpBufLength(); |
andrewboyson | 55:e64b8b47a2b6 | 36 | |
andrewboyson | 55:e64b8b47a2b6 | 37 | if (HttpTrace) |
andrewboyson | 55:e64b8b47a2b6 | 38 | { |
andrewboyson | 55:e64b8b47a2b6 | 39 | LogF("HTTP >>> %d (%d)\r\n", *pSize, positionInReplyStream); |
andrewboyson | 55:e64b8b47a2b6 | 40 | } |
andrewboyson | 71:736a5747ade1 | 41 | } |