From 6ad4a234bd58a2738d7baa04f758e324e322ea69 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 23 Nov 2014 11:25:38 +0100 Subject: added a POST method to http-tiny --- src/3rdParty/http_tiny/http_lib.c | 30 ++++++++++++++++++++++++++++++ src/3rdParty/http_tiny/http_lib.h | 3 +++ 2 files changed, 33 insertions(+) (limited to 'src/3rdParty') diff --git a/src/3rdParty/http_tiny/http_lib.c b/src/3rdParty/http_tiny/http_lib.c index a3ee603..f11df19 100644 --- a/src/3rdParty/http_tiny/http_lib.c +++ b/src/3rdParty/http_tiny/http_lib.c @@ -285,6 +285,36 @@ http_retcode http_put(filename, data, length, overwrite, type) return http_query("PUT",filename,header,CLOSE, data, length, NULL); } +/* + * Post data to the server + * + * This function sends data to the http data server. + * The data will be handled by the server, especially the resource + * URI has no direct influence on the storage location of the data + * of the request. + * returns a negative error code or a positive code from the server + * + * limitations: filename is truncated to first 256 characters + * and type to 64. + */ +http_retcode http_post(filename, data, length, type) + char *filename; /* name of the ressource to create */ + char *data; /* pointer to the data to send */ + int length; /* length of the data to send */ + char *type; /* type of the data, if NULL default type is used */ +{ + char header[MAXBUF]; + if (type) + sprintf(header,"Content-length: %d\015\012Content-type: %.64s\015\012", + length, + type + ); + else + sprintf(header,"Content-length: %d\015\012",length + ); + return http_query("POST",filename,header,CLOSE, data, length, NULL); +} + /* * Get data from the server diff --git a/src/3rdParty/http_tiny/http_lib.h b/src/3rdParty/http_tiny/http_lib.h index 1fb7c97..cd63c7c 100644 --- a/src/3rdParty/http_tiny/http_lib.h +++ b/src/3rdParty/http_tiny/http_lib.h @@ -69,4 +69,7 @@ http_retcode http_delete(char *filename) ; http_retcode http_head(char *filename, int *plength, char *typebuf); +http_retcode http_post(char *filename, char *data, int length, + char *type) ; + #endif -- cgit v1.2.3-54-g00ecf