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: RPC_HTTP RPC_HTTP_WIZnetInterface RPC_HTTP rpc_over_http_TL_interrupter_gatePJ
Fork of HTTPServer by
Revision 7:cb7fec1265b5, committed 2013-06-01
- Comitter:
- leihen
- Date:
- Sat Jun 01 17:47:45 2013 +0000
- Parent:
- 6:fe661fa9d18a
- Child:
- 8:ccbdf6e28655
- Child:
- 9:c2a1462b9b71
- Commit message:
- Fixed a Problem with incorrect HttpBody size when returning GET Request data.
; Fixed incorrect variable size for returned data, which led to a Problem when returned data length exceeds 65535 Bytes.
Changed in this revision
--- a/HTTPRequestHandler.cpp Sat Jun 01 16:49:17 2013 +0000
+++ b/HTTPRequestHandler.cpp Sat Jun 01 17:47:45 2013 +0000
@@ -86,13 +86,13 @@
}
-void HTTPRequestHandler::startResponse(int returnCode, int nLen, HTTPHeaders* header)
+void HTTPRequestHandler::startResponse(int returnCode, long nLen, HTTPHeaders* header)
{
- INFO("Starting response !");
+ INFO("Starting response (%ld bytes in total)!", nLen);
tcp.set_blocking(true, 1500);
sprintf(buffer, "HTTP/1.1 %d OK\r\n", returnCode);
tcp.send(buffer, strlen(buffer));
- sprintf(buffer, "Content-Length: %d\r\n", nLen + 2); // Add 2 chars for the terminating CR+LF
+ sprintf(buffer, "Content-Length: %ld\r\n", nLen); // Add 2 chars for the terminating CR+LF
tcp.send(buffer, strlen(buffer));
if (header == NULL) {
sprintf(buffer, "Content-Type: text/html\r\nServer: mbed embedded\r\n\r\n");
@@ -112,7 +112,7 @@
void HTTPRequestHandler::processResponse(int nLen, char* body)
{
- INFO("Processing Response !");
+ INFO("Processing Response (%d bytes)!\n",nLen);
tcp.send(body, nLen);
}
--- a/HTTPRequestHandler.h Sat Jun 01 16:49:17 2013 +0000
+++ b/HTTPRequestHandler.h Sat Jun 01 17:47:45 2013 +0000
@@ -116,7 +116,7 @@
* automatically added in \c startResponse. if you need to change the headers, please do NOT
* specify the \c Content-Length Header. This is done automatically be the function.
*/
- void startResponse(int returnCode, int nLen, HTTPHeaders* header = NULL);
+ void startResponse(int returnCode, long nLen, HTTPHeaders* header = NULL);
void processResponse(int nLen, char* body );
void endResponse();
--- a/Handler/FsHandler.cpp Sat Jun 01 16:49:17 2013 +0000
+++ b/Handler/FsHandler.cpp Sat Jun 01 17:47:45 2013 +0000
@@ -16,7 +16,7 @@
#endif
-#define MAX_BUFFERSIZE 128
+#define MAX_BUFFERSIZE 512
static char buffer[MAX_BUFFERSIZE];
@@ -73,6 +73,8 @@
startResponse(200, size);
while(!feof(fp) && !ferror(fp)) {
int cnt = fread(buffer, 1, MAX_BUFFERSIZE , fp);
+ if (cnt < 0)
+ cnt = 0;
processResponse(cnt, buffer);
}
endResponse();
