From 323b3949ce72e6fa5163da5a48ee885d04810c2f Mon Sep 17 00:00:00 2001 From: Ferràn Quer i Guerrero Date: Thu, 20 Mar 2014 07:23:26 +0000 Subject: [PATCH] --- Project/applications/smartcities/httpClient.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ Project/applications/smartcities/include/httpClient.h | 25 +++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 0 deletions(-) create mode 100644 Project/applications/smartcities/httpClient.c create mode 100644 Project/applications/smartcities/include/httpClient.h diff --git a/Project/applications/smartcities/httpClient.c b/Project/applications/smartcities/httpClient.c new file mode 100644 index 0000000..6e32fcd --- /dev/null +++ b/Project/applications/smartcities/httpClient.c @@ -0,0 +1,50 @@ +#include "httpClient.h" + +/* +------------ +POST request +------------ +POST /path/script.cgi HTTP/1.0 +From: frog@jmarshall.com +User-Agent: HTTPTool/1.0 +Content-Type: application/x-www-form-urlencoded +Content-Length: 32 + +home=Cosby&favorite+flavor=flies +----------- +GET request +----------- +"GET $path HTTP/1.1\015\012", + "Host: $host\015\012", + "Connection: close\015\012", + "User-Agent: GetURL11/1.0\015\012\015\012" ; +------------ +POST REQUEST +------------ +POST https://www.easypolls.net/polladm +Host: www.easypolls.net +User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 +Accept: application/json, text/javascript, *\/*; q=0.01 +Accept-Language: ca,en;q=0.8,en-us;q=0.6,es-es;q=0.4,es;q=0.2 +Accept-Encoding: gzip, deflate +Content-Type: application/x-www-form-urlencoded; charset=UTF-8 +X-Requested-With: XMLHttpRequest +Referer: https://www.easypolls.net/ +Content-Length: 55 +Cookie: AWSELB=47292F3B1ABE6284EA92626CE03FD9D94424CDF5A4944582983CE557A13B86D33CD0A0B08CB1F9B3F96C4EB2EB02C3C2B05BACD02900197E12E24FFBC154B412B3DBEC7AA9; __utma=223536783.418364988.1395162582.1395162582.1395162582.1; __utmb=223536783.1.10.1395162582; __utmc=223536783; __utmz=223536783.1395162582.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); JSESSIONID=4A2F288CE32F6F940ACA69C5AB4C41C8; __atuvc=1%7C12 +Connection: keep-alive +Pragma: no-cache +Cache-Control: no-cache + +command=login&email=mail%40host.com&password=lskdfja +----------- +GET REQUEST +----------- +GET /path/file.html HTTP/1.1 +Host: www.host1.com:80 + +[Content] +*/ + +//const static char httpHeaders[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; +const static char httpHeaders[] = "HTTP/1.1 OK\r\nContent-type: text/html\r\n\r\n"; diff --git a/Project/applications/smartcities/include/httpClient.h b/Project/applications/smartcities/include/httpClient.h new file mode 100644 index 0000000..a216d4f --- /dev/null +++ b/Project/applications/smartcities/include/httpClient.h @@ -0,0 +1,25 @@ +/* + * Custom http client implementation based on httpServer + * + */ +#ifndef HTTP_CLIENT_H +#define HTTP_CLIENT_H + +#include "libwismart.h" +#include "lwip/opt.h" +#include "lwip/tcp.h" +#include "lwip/udp.h" +#include "lwip/sys.h" +#include "lwip/api.h" +#include "ch.h" + +#define DBG(fmt,...) if(1){printf("[SRV] "fmt"\r\n", ##__VA_ARGS__);}else{({});} +#define DBG_WARNING(fmt,...) if(1){printf("[SRV_WARNING] "fmt"\r\n", ##__VA_ARGS__);}else{({});} + +void httpServer_init(void); +void httpServer_start(void); +msg_t httpServer_threadFunc(void *arg); +void httpServer_serveClient(struct netconn* httpClientConnection); +void getLocalTime(uint32_t* hours, uint32_t* minutes, uint32_t* seconds); + +#endif \ No newline at end of file -- libgit2 0.22.2