summaryrefslogtreecommitdiffstats
path: root/nanohttp/nanohttp-client.h
diff options
context:
space:
mode:
authorGravatar m0gg2006-12-08 21:21:41 +0000
committerGravatar m0gg2006-12-08 21:21:41 +0000
commit46ec9aea1caadcec41ff5637c0bb2b906a2a2041 (patch)
treecd8b09aa8de70dd1b57d3df935e31540bba1b88d /nanohttp/nanohttp-client.h
parent327f375e02d4282f973d0fb96e82b99858b32719 (diff)
downloadcsoap-46ec9aea1caadcec41ff5637c0bb2b906a2a2041.tar.gz
csoap-46ec9aea1caadcec41ff5637c0bb2b906a2a2041.tar.bz2
hurl_t moved to nanohttp-url.[ch]
Diffstat (limited to 'nanohttp/nanohttp-client.h')
-rw-r--r--nanohttp/nanohttp-client.h125
1 files changed, 123 insertions, 2 deletions
diff --git a/nanohttp/nanohttp-client.h b/nanohttp/nanohttp-client.h
index 69807f7..72cba96 100644
--- a/nanohttp/nanohttp-client.h
+++ b/nanohttp/nanohttp-client.h
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: nanohttp-client.h,v 1.29 2006/12/02 21:50:47 m0gg Exp $
+ * $Id: nanohttp-client.h,v 1.30 2006/12/08 21:21:41 m0gg Exp $
*
* CSOAP Project: A http client/server library in C
* Copyright (C) 2003 Ferhat Ayaz
@@ -34,11 +34,132 @@
#include <nanohttp/nanohttp-logging.h>
#endif
+/** @file
+ *
+ * Writing an HTTP client using nanoHTTP
+ *
+ * - Client initialization
+ * - Connection initialization
+ * -- SSL related functions
+ * - Setting HTTP headers (optional)
+ * -- Setting an HTTP header with uniq key
+ * -- Setting multiple headers
+ * - Fetch the network resource
+ * -- HTTP GET command
+ * -- HTTP POST command
+ * -- MIME attachments
+ * - Print out the result
+ * - Connection cleanup
+ * - Client cleanup
+ *
+ * Client initialization
+ *
+ * int main(int argc, char **argv)
+ * {
+ * herror_t status;
+ * size_t len;
+ * httpc_conn_t conn;
+ *
+ * if (argc < 2)
+ * {
+ * fprintf(stderr, "usage: %s <url> [nanoHTTP params]\n", argv[0]);
+ * exit(1);
+ * }
+ *
+ * if ((status = httpc_init(argc, argv)) != H_OK)
+ * {
+ * fprintf(stderr, "Cannot init nanoHTTP client (%s)\n", herror_message(status));
+ * herror_release(status);
+ * exit(1);
+ * }
+ *
+ * Connection initialization
+ *
+ * if (!(conn = httpc_new()))
+ * {
+ * fprintf(stderr, "Cannot create nanoHTTP client connection\n");
+ * httpc_destroy();
+ * exit(1);
+ * }
+ *
+ * SSL related functions
+ *
+ * T.B.D.
+ *
+ * Setting HTTP headers (optional)
+ *
+ * httpc_set_header(conn, "my-key", "my-value");
+ *
+ * httpc_add_header(conn, "Cookie", "name1:value1");
+ * httpc_add_header(conn, "Cookie", "name2:value2");
+ *
+ * Fetch the network resource
+ *
+ * HTTP GET command
+ *
+ * if ((status = httpc_get(conn, &result, argv[1])) != H_OK)
+ * {
+ * fprintf(stderr, "nanoHTTP client connection failed (%s)\n", herror_message(status));
+ * herror_release(status);
+ * httpc_destroy();
+ * exit(1);
+ * }
+ *
+ * HTTP POST command
+ *
+ * if ((status = httpc_post_begin(conn, argv[1])) != H_OK)
+ * {
+ * fprintf(stderr, "nanoHTTP client connection failed (%s)\n", herror_message(status));
+ * herror_release(status);
+ * httpc_destroy();
+ * exit(1);
+ * }
+ *
+ * if ((status = http_output_stream_write(conn->out, buffer, len)) != H_OK)
+ * {
+ * fprintf(stderr, "nanoHTTP client sending POST data failed (%s)\n", herror_message(status));
+ * herror_release(status);
+ * httpc_destroy();
+ * exit(1);
+ * }
+ *
+ * if ((status = httpc_post_end(conn, &result)) != H_OK)
+ * {
+ * fprintf(stderr, "nanoHTTP client POST failed (%s)\n", herror_message(status));
+ * herror_release(status);
+ * httpc_destroy();
+ * exit(1);
+ * }
+ *
+ * MIME attachments
+ *
+ * T.B.D.
+ *
+ * Print out the result
+ *
+ * while (http_input_stream_is_read(res->in))
+ * {
+ * len = http_input_stream_read(res->in, buffer, MAX_BUFFER_SIZE);
+ * fwrite(buffer, len, 1, stdout);
+ * }
+ *
+ * Connection cleanup
+ *
+ * hresponse_free(res);
+ *
+ * Client cleanup
+ *
+ * httpc_free(conn);
+ *
+ * }
+ *
+ */
+
typedef struct httpc_conn
{
struct hsocket_t *sock;
hpair_t *header;
- hurl_t url;
+ struct hurl_t *url;
http_version_t version;
int errcode;