Networking stack: HTTP Client Streaming example

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Thu May 27 10:16:27 2010 +0000
Child:
1:0e4f1cc78052
Commit message:

Changed in this revision

HttpClientStreamingExample.cpp Show annotated file Show diff for this revision Revisions of this file
NetEthApiLPC1768.lib Show annotated file Show diff for this revision Revisions of this file
NetServicesLPC1768.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HttpClientStreamingExample.cpp	Thu May 27 10:16:27 2010 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HttpClient.h"
+
+EthernetNetIf eth; 
+HttpClient http;
+
+HttpResult result;
+bool completed = false;
+void request_callback(HttpResult r)
+{
+  result = r;
+  printf("\r\n-----Err %d-----\r\n", r);
+  completed = true;
+}
+  
+Serial pc(USBTX, USBRX);
+
+int main() {
+
+  pc.baud(115200);
+
+  printf("Start\n");
+
+  printf("\r\nSetting up...\r\n");
+  EthernetErr ethErr = eth.setup();
+  if(ethErr)
+  {
+    printf("Error %d in setup.\n", ethErr);
+    return -1;
+  }
+  printf("\r\nSetup OK\r\n");
+  
+  HttpStream stream;
+  
+  char BigBuf[1024 + 1] = {0};
+  stream.readNext((byte*)BigBuf, 1024);
+  
+  HttpResult r = http.get("http://mbed.org/", &stream, request_callback);
+  
+  while(!completed)
+  {
+    Net::poll();
+    if(stream.readable())
+    {
+      BigBuf[stream.readLen()+1] = 0;
+      printf("%s",BigBuf);
+      stream.readNext((byte*)BigBuf, 1024);
+    }
+  }
+  printf("\r\n--------------\r\n");
+  if(result == HTTP_OK)
+  {
+    printf("Read completely\n"); 
+  }
+  else
+  {
+    printf("Error %d\n", r);
+  }
+  
+  while(1)
+  {
+  
+  }
+  
+  return 0;
+  
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NetEthApiLPC1768.lib	Thu May 27 10:16:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NetEthApiLPC1768/#2929fcb16bbf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NetServicesLPC1768.lib	Thu May 27 10:16:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/NetServicesLPC1768/#acb9b7d53771
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 27 10:16:27 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e6be4cd80aad