HTTPicus – Flyport Http request made easy

Posted by openPicus | On: Oct 31 2012
Hello community!
Today we want to present HTTPicus, a simple library to execute http requests to a remote server easily. 
HTTPicus is developed by Diego Luca Candido a geek from our community that we met at the recent Hackaton we held in July. All this work and it’s released under GPL v2.

The need to build this lib, came from the lack of a straightforward and simple library to make http requests from Flyports.

So ok, let’s see what can we do with this library!

We can do GET and POST to a remote server with a with a variable number of arguments with just few lines of code:
All you need is to clone the repository at: https://github.com/joxer/HTTPicus
Take the two files (httplib.c and httplib.h) and insert them into the
Openpicus IDE.

An example will show you better how easy it is:
 #ifndef TASK_FLYPORT_H  
#define TASK_FLYPORT_H
#include "taskFlyport.h"
#endif
#include "httplib.h"
void FlyportTask()
{
vTaskDelay(100);
WFConnect(WF_DEFAULT);
while (WFStatus != CONNECTED);
TCP_SOCKET* socket = create_http_socket("google.it");
struct HTTP_HEADER_REQUEST pp;
pp.method = "GET";
pp.resource = "/";
pp.version = "HTTP/1.1";
pp.host = "www.google.it";
pp.parameters_size = 0;
char* request = get_http_request(&pp);
do_http_request(socket,request)
char* response = http_get_response(socket);
UARTWrite(1,response);
closeSocket(socket);
while(1)
{
vTaskDelay(200);
}
}

The following code makes a GET requesto to http://google.com and returns the response from the server. For a better explanation of the code check the wiki here: http://wiki.openpicus.com/index.php?title=HTTPicus

The implementation of the HTTP is far from being complete, so feel free to join the develop of it and fork on github the repository. All you can do it’s appreciated. To contact Diego, mail him or check him on twitter.

3 Comments

  1. Cesare says:

    httplib.c and httplib.h
    Can you specify where copy these files?

    and heap.s?

  2. openPicus says:

    Yes we removed since this library had a lot of bugs and we decided to make a new one. We are working on this, we think to release in December

Leave a comment