httpClient.h 1.11 KB
/*
 * 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"
#include "globals.h"

#define DEFAULT_REMOTE_IP  "147.83.2.135" // www.upc.edu
#define DEFAULT_REMOTE_PORT 80
#define ENDL "\r\n"
#define CONTENT_TYPE_HEADER "Content-Type: application/json; charset=UTF-8"

#define DBG_HTTP(fmt,...)                printf("%c[1;35mhttpClient.c:%c[1;00m "fmt,0x1B,0x1B, ##__VA_ARGS__)
//#define DBG_HTTP(fmt,...)                printf("")


typedef enum reqMethod
{
	post,
	get,
	put,
	del //delete may be a special word.
	
}reqMethod;

typedef struct httpHeaders
{
	enum reqMethod method;
	char* uri;
	int uri_size;
	char* host;
	int host_size;
	
}httpHeaders;


int httpRequest(struct httpHeaders head, char* content, int content_size);
const char* reqMethod2text(enum reqMethod method);
char* int2string(int num);
int numberofdigits(int number);
int response2int(char* chars);

#endif