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
Revision 166:89e3ce39b31b, committed 2020-04-02
- Comitter:
- andrewboyson
- Date:
- Thu Apr 02 11:58:33 2020 +0000
- Parent:
- 165:29a9e5f2eaef
- Child:
- 167:3ba4e3c49631
- Commit message:
- Added a httpv (vanilla HTTP) module to TCP which does a similar job to https (HTTP over TCP) and allows the http module to be independent of its caller.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tcp/https/https.c Thu Apr 02 11:58:33 2020 +0000
@@ -0,0 +1,22 @@
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "tls.h"
+#include "http.h"
+
+bool HttpsGetTrace()
+{
+ return HttpGetTrace() || TlsTrace;
+}
+void HttpsReset(int connectionId)
+{
+ TlsReset(connectionId);
+}
+bool HttpsResponse(int connectionId, bool clientFinished, int* pWindowSize, uint8_t* pWindow, uint32_t windowPositionInStream)
+{
+ return TlsResponse(connectionId, clientFinished, pWindowSize, pWindow, windowPositionInStream);
+}
+void HttpsRequest (int connectionId, int windowSize, uint8_t* pWindow, uint32_t windowPositionInStream)
+{
+ TlsRequest(connectionId, windowSize, pWindow, windowPositionInStream);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tcp/https/https.h Thu Apr 02 11:58:33 2020 +0000 @@ -0,0 +1,7 @@ +#include <stdint.h> +#include <stdbool.h> + +extern bool HttpsGetTrace(void); +extern void HttpsReset (int connectionId); +extern bool HttpsResponse(int connectionId, bool clientFinished, int* pWindowSize, uint8_t* pWindow, uint32_t windowPositionInStream); +extern void HttpsRequest (int connectionId, int windowSize, uint8_t* pWindow, uint32_t windowPositionInStream); \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tcp/httpv/httpv.c Thu Apr 02 11:58:33 2020 +0000
@@ -0,0 +1,27 @@
+#include <stdbool.h>
+#include <http.h>
+
+bool HttpvGetTrace()
+{
+ return HttpGetTrace();
+}
+void HttpvReset(int connectionId)
+{
+ HttpReset(connectionId);
+}
+bool HttpvResponse(int connection, bool clientFinished, int* pWindowSize, uint8_t* pWindow, uint32_t windowPositionInStream)
+{
+ int status = HttpPoll(connection, clientFinished);
+ bool finished;
+ switch (status)
+ {
+ case HTTP_WAIT: finished = false; *pWindowSize = 0; break;
+ case HTTP_FINISHED: finished = true; *pWindowSize = 0; break;
+ case HTTP_HAVE_SOMETHING_TO_SEND: finished = HttpAdd(connection, pWindowSize, (char*)pWindow, windowPositionInStream); break;
+ }
+ return finished;
+}
+void HttpvRequest (int connectionId, int windowSize, uint8_t* pWindow, uint32_t windowPositionInStream)
+{
+ HttpRequest(connectionId, windowSize, (char*)pWindow, windowPositionInStream);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tcp/httpv/httpv.h Thu Apr 02 11:58:33 2020 +0000 @@ -0,0 +1,7 @@ +#include <stdint.h> +#include <stdbool.h> + +extern bool HttpvGetTrace(void); +extern void HttpvReset (int connectionId); +extern bool HttpvResponse(int connectionId, bool clientFinished, int* pWindowSize, uint8_t* pWindow, uint32_t windowPositionInStream); +extern void HttpvRequest (int connectionId, int windowSize, uint8_t* pWindow, uint32_t windowPositionInStream);
--- a/tcp/tcprecv.c Wed Apr 01 13:36:27 2020 +0000
+++ b/tcp/tcprecv.c Thu Apr 02 11:58:33 2020 +0000
@@ -11,7 +11,7 @@
#include "tcb.h"
#include "ip4.h"
#include "dhcp.h"
-#include "http.h"
+#include "httpv.h"
#include "https.h"
#include "led.h"
#include "mstimer.h"
@@ -51,7 +51,7 @@
pTcb->bytesSentToRem = 0;
switch (pTcb->locPort) //Reset the application
{
- case 80: HttpReset(TcbGetId(pTcb)); break;
+ case 80: HttpvReset(TcbGetId(pTcb)); break;
case 443: HttpsReset(TcbGetId(pTcb)); break;
}
}
@@ -61,8 +61,8 @@
uint8_t* pData = (uint8_t*)pPacket + TcpHdrSizeGet();
switch (pTcb->locPort)
{
- case 80: HttpRequest(TcbGetId(pTcb), dataLength, (char*)pData, position); break;
- case 443: HttpsRequest(TcbGetId(pTcb), dataLength, pData, position); break;
+ case 80: HttpvRequest(TcbGetId(pTcb), dataLength, pData, position); break;
+ case 443: HttpsRequest(TcbGetId(pTcb), dataLength, pData, position); break;
}
}
static int sendResetFromPacket(int* pSizeTx, void* pPacketTx, int ipType, int remArIndex, int locIpScope, int seqLengthRcvd)
@@ -135,7 +135,7 @@
switch (TcpHdrDstPort)
{
case 80:
- if (HttpGetTrace())
+ if (HttpvGetTrace())
{
if (NetTraceNewLine) Log("\r\n");
LogTime("HTTP server request\r\n");
--- a/tcp/tcpsend.c Wed Apr 01 13:36:27 2020 +0000
+++ b/tcp/tcpsend.c Thu Apr 02 11:58:33 2020 +0000
@@ -10,7 +10,7 @@
#include "tcb.h"
#include "ip4.h"
#include "dhcp.h"
-#include "http.h"
+#include "httpv.h"
#include "https.h"
#include "led.h"
#include "tcpsend.h"
@@ -38,7 +38,7 @@
{
switch (port)
{
- case 80: return HttpGetTrace();
+ case 80: return HttpvGetTrace();
case 443: return HttpsGetTrace();
default: return false;
}
@@ -51,8 +51,8 @@
*pDataLength = windowSize;
switch (port)
{
- case 80: finished = HttpResponse(connection, clientFinished, pDataLength, (char*)pWindow, windowPositionInStream); break;
- case 443: finished = HttpsResponse(connection, clientFinished, pDataLength, pWindow, windowPositionInStream); break;
+ case 80: finished = HttpvResponse(connection, clientFinished, pDataLength, pWindow, windowPositionInStream); break;
+ case 443: finished = HttpsResponse(connection, clientFinished, pDataLength, pWindow, windowPositionInStream); break;
}
return finished;
}