diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-11-23 11:25:38 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-11-23 11:25:38 +0100 |
commit | 6ad4a234bd58a2738d7baa04f758e324e322ea69 (patch) | |
tree | 25643528c5aa485ce7d26d1647091655d456622b /src/3rdParty | |
parent | 412e546bb9a982c2db389c35496bf397e5f25a46 (diff) | |
download | biruda-6ad4a234bd58a2738d7baa04f758e324e322ea69.tar.gz biruda-6ad4a234bd58a2738d7baa04f758e324e322ea69.tar.bz2 |
added a POST method to http-tiny
Diffstat (limited to 'src/3rdParty')
-rw-r--r-- | src/3rdParty/http_tiny/http_lib.c | 30 | ||||
-rw-r--r-- | src/3rdParty/http_tiny/http_lib.h | 3 |
2 files changed, 33 insertions, 0 deletions
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 |