diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-02-01 16:48:20 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-02-01 20:07:09 -0800 |
| commit | 5e5f814d63d4e00365b0ae726bc18831aa28e88f (patch) | |
| tree | 804a930d4f9f941cd75e156f169a52e7110ef1e9 /src/nng.h | |
| parent | 3dae30ed5e543dc73fc993334ef56b9b157b9b3c (diff) | |
| download | nng-5e5f814d63d4e00365b0ae726bc18831aa28e88f.tar.gz nng-5e5f814d63d4e00365b0ae726bc18831aa28e88f.tar.bz2 nng-5e5f814d63d4e00365b0ae726bc18831aa28e88f.zip | |
fixes #174 Define public HTTP client API
Diffstat (limited to 'src/nng.h')
| -rw-r--r-- | src/nng.h | 38 |
1 files changed, 30 insertions, 8 deletions
@@ -322,14 +322,6 @@ NNG_DECL int nng_aio_set_output(nng_aio *, unsigned, void *); // nng_aio_get_output retrieves the output result at the given index. NNG_DECL void *nng_aio_get_output(nng_aio *, unsigned); -// nng_aio_set_data sets an opaque data at the given index. The intention -// is to allow consumers to pass additional state for use in callback -// functions. -NNG_DECL int nng_aio_set_data(nng_aio *, unsigned, void *); - -// nng_aio_get_data retrieves the data that was previously stored. -NNG_DECL void *nng_aio_get_output(nng_aio *, unsigned); - // nng_aio_set_timeout sets a timeout on the AIO. This should be called for // operations that should time out after a period. The timeout should be // either a positive number of milliseconds, or NNG_DURATION_INFINITE to @@ -1184,6 +1176,36 @@ NNG_DECL int nng_http_server_get_tls(nng_http_server *, nng_tls_config **); NNG_DECL int nng_http_hijack(nng_http_conn *); +// nng_http_client represents a "client" object. Clients can be used +// to create HTTP connections. At present, connections are not cached +// or reused, but that could change in the future. +typedef struct nng_http_client nng_http_client; + +// nng_http_client_alloc allocates a client object, associated with +// the given URL. +NNG_DECL int nng_http_client_alloc(nng_http_client **, const nng_url *); + +// nng_http_client_free frees the client. Connections created by the +// the client are not necessarily closed. +NNG_DECL void nng_http_client_free(nng_http_client *); + +// nng_http_client_set_tls sets the TLS configuration. This wipes out +// the entire TLS configuration on the client, so the caller must have +// configured it reasonably. This API is not recommended unless the +// caller needs complete control over the TLS configuration. +NNG_DECL int nng_http_client_set_tls(nng_http_client *, nng_tls_config *); + +// nng_http_client_get_tls obtains the TLS configuration if one is present, +// or returns NNG_EINVAL. The supplied TLS configuration object may +// be invalidated by any future calls to nni_http_client_set_tls. +NNG_DECL int nng_http_client_get_tls(nng_http_client *, nng_tls_config **); + +// nng_http_client_connect establishes a new connection with the server +// named in the URL used when the client was created. Once the connection +// is established, the associated nng_http_conn object pointer is returned +// in the first (index 0) output for the aio. +NNG_DECL void nng_http_client_connect(nng_http_client *, nng_aio *); + #ifdef __cplusplus } #endif |
