Search Notebooks
lwIP HTTPClient/HTTPServer

How to set up the lwip HTTPClient and HTTPServer class. Some useful informations and some small examples. Furthermore the progress, known bugs and known workarounds.

ethernet, http, HTTPClient, HTTPServer, lwip

Page owner: user Rolf Meyer

Created 18 Nov 2009.
Last updated 02 Dec 2009

lwIP HTTPClient/HTTPServer

Page last updated 02 Dec 2009, by   user Rolf Meyer   tag ethernet, http, HTTPClient, HTTPServer, lwip | 2 replies  

I've ported over the lwIP TCP/IP stack to mbed to provide an HTTPClient and HTTPServer. There is no RTOS on the mbed target available so it has to run in the same thread of execution as the application therefore it uses a poll based model. To leave more RAM to the application it shares the network RAM space with the lowlevel driver (ETH RAM on LPC2368, AHBSRAM1 on LPC1768).

It uses the mbed Ethernet class as a back end driver. To use just the Ethernet class have a look _ _here. This is most of enough if you just want to send a UDP packet or broadcast big chunks of data into a network.

 

Import Library:

http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk

or import precompiled Library:

http://mbed.org/projects/cookbook/svn/EMAC/lwip/precomp

 

Ethernet plug

To use it you need to connect your Ethernet correctly. How to do it you may find out at my Ethernet page.

 

HTTPClient

The HTTPClient class provides an easy interface to HTTP GET/POST. You can download files from HTTP servers or update data on your HTTP server.

At the current state it allows the download in normal mode, chunk mode is not denied but the chunks are not recognized. Furthermore the size of the page is currently not detected right, you might get garbage at the end.

A Twitter Hello World

#include "mbed.h"
#include "HTTPClient.h"

DigitalOut led(LED1);
HTTPClient http;
 
const char user[] = "[your twitter username]";
const char pass[] = "[your twitter password]";
const char msg[] = "status=Hello World from an mbed";
const char url[]  = "http://twitter.com/statuses/update.xml";

int main(void) {
    http.auth(user, pass);
    http.post(url, msg);

    while(1) {
        led = !led;
        wait(0.2);
    }
}

Twitter

HTTPServer

The HTTPServer class provides an HTTP server for your mbed. You can go to your mbed with your Web browser and access the file system or ask some sensor values.

 

Development Log

Tools

Useful tools to debug are:

More

For more information have a look at these pages:
HomepageSavannahWiki )


2 comments

20 Nov 2009

Where can one find this library please :)

06 Apr 2010

Hi Rolf

HTTPClient ... At the current state it allows the download in normal mode, chunk mode is not denied but the chunks are not recognized.

Since chunks are not recognized, can you provide the option to use a HTTP/1.0 GET request rather than HTTP/1.1? In this way, the server will not use transfer encoding so avoiding chunks altogether.

Thanks
Daniel

Please log in to post a comment.