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.
Revision 271:06c2c2a4e0bf, committed 2020-06-17
- Comitter:
- nixnax
- Date:
- Wed Jun 17 21:43:37 2020 +0000
- Parent:
- 270:98099fbc46fb
- Child:
- 272:9ea94556c6f6
- Commit message:
- Changed HTTP header response code
Changed in this revision
| PPP-Blinky/ppp-blinky.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/PPP-Blinky/ppp-blinky.cpp Tue Jun 02 18:32:40 2020 +0000
+++ b/PPP-Blinky/ppp-blinky.cpp Wed Jun 17 21:43:37 2020 +0000
@@ -117,7 +117,7 @@
<h1>TCP, LCP & Ping Count: 0000000000</h1>\
<h1>System Core Clock: 0000000000</h1>\
</body>\
-</html>\r\n"; // size = 682 bytes + 1 null byte = 683 bytes
+</html>\r\n"; // size = 718 bytes + 1 null byte = 719 bytes
// this is a websocket demo html page we serve when GET /ws is requested
// it contains some javascript to handle the websocket activities
@@ -901,16 +901,17 @@
httpGet5 = dataStart[5]; // the first character in the path name, we use it for special functions later on
httpGet6 = dataStart[6]; // the second character in the path name, we use it for special functions later on
// for example, you could try this using netcat (nc): echo "GET /x" | nc 172.10.10.2
+ n=n+sprintf(n+dataStart,"HTTP/1.1 "); // start of response header
if( (httpGetRoot==0) || (httpGetx==0) || (httpGet5 == 'w' ) ) {
- n=n+sprintf(n+dataStart,"HTTP/1.1 200 OK\r\nServer: mbed PPP-Blinky\r\n"); // 200 OK header
+ n=n+sprintf(n+dataStart,"200 OK\r\n"); // 200 OK header
} else {
- n=n+sprintf(n+dataStart,"HTTP/1.1 404 Not Found\r\nServer: mbed PPP-Blinky\r\n"); // 404 header
+ n=n+sprintf(n+dataStart,"404 Not Found\r\n"); // 404 header
}
- n=n+sprintf(n+dataStart,"Content-Length: "); // http header
- contentLengthStart = n; // remember where Content-Length is in buffer
- n=n+sprintf(n+dataStart,"?????\r\n"); // leave five spaces for content length - will be updated later
- //n=n+sprintf(n+dataStart,"Connection: close\r\n"); // close connection immediately
-#define SHOWMAXBUFLEVEL_YES
+#define SHOWSERVERNAME_NO
+#ifdef SHOWSERVERNAME_YES
+ n=n+sprintf(n+dataStart,"Server: mbed PPP-Blinky\r\n"); // Server in response header
+#endif
+#define SHOWMAXBUFLEVEL_NO
#ifdef SHOWMAXBUFLEVEL_YES
// if this is enabled then the maximum value of the serial port receive buffer will show up in the http headers of your browser - nice for debugging
n=n+sprintf(n+dataStart,"Maxbuflevel: %d\r\n", ppp.rx.maxbuflevel);
@@ -920,9 +921,10 @@
// if this is enabled then the received PPP packet count will show up in the http headers of your browser - disabled for now because it's also displayed in the root page
n=n+sprintf(n+dataStart,"PPP-RX-Packets: %d\r\n", ppp.pppCount);
#endif
- n=n+sprintf(n+dataStart,"Content-Type: text/html; charset=us-ascii\r\n\r\n"); // http header must end with empty line (\r\n)
- nHeader=n; // size of HTTP header
-
+ n=n+sprintf(n+dataStart,"Content-Type: text/html; charset=us-ascii\r\n"); // http header must end with empty line (\r\n)
+ n=n+sprintf(n+dataStart,"Content-Length: ?????\r\n\r\n"); // leave five spaces for content length - will be updated later
+ contentLengthStart = n-9; // remember where Content-Length starts in the buffer
+ nHeader=n; // size of HTTP header and start of payload
if( httpGetRoot == 0 ) {
// this is where we insert our web page into the buffer
memcpy(n+dataStart,rootWebPage,sizeof(rootWebPage));