@@ -147,7 +147,7 @@ NNG_DECL void nng_http_reset(nng_http *);
147
147
// include an optional query string, either inline in the URI to start,
148
148
// or as a separate argument. If the query string already exists
149
149
// and one is also supplied here, it will be appended (separated with &).
150
- NNG_DECL int nng_http_set_uri (nng_http * , const char * , const char * );
150
+ NNG_DECL nng_err nng_http_set_uri (nng_http * , const char * , const char * );
151
151
152
152
// nng_http_get_uri returns the URI. It will be NULL if not set.
153
153
NNG_DECL const char * nng_http_get_uri (nng_http * );
@@ -167,7 +167,7 @@ NNG_DECL void nng_http_set_status(nng_http *, uint16_t, const char *);
167
167
// nng_http_set_version is used to change the version of a request.
168
168
// Normally the version is "HTTP/1.1". Note that the framework does
169
169
// not support HTTP/2 at all. Null sets the default ("HTTP/1.1").
170
- NNG_DECL int nng_http_set_version (nng_http * , const char * );
170
+ NNG_DECL nng_err nng_http_set_version (nng_http * , const char * );
171
171
172
172
// nng_http_get_version is used to get the version of a request.
173
173
NNG_DECL const char * nng_http_get_version (nng_http * );
@@ -184,8 +184,8 @@ NNG_DECL const char *nng_http_get_method(nng_http *);
184
184
// a header to either the request or response. Clients modify the request
185
185
// headers, and servers (and callbacks on the server) modify response headers.
186
186
// These can return NNG_ENOMEM, NNG_MSGSIZE, etc.
187
- NNG_DECL int nng_http_set_header (nng_http * , const char * , const char * );
188
- NNG_DECL int nng_http_add_header (nng_http * , const char * , const char * );
187
+ NNG_DECL nng_err nng_http_set_header (nng_http * , const char * , const char * );
188
+ NNG_DECL nng_err nng_http_add_header (nng_http * , const char * , const char * );
189
189
190
190
// nng_http_del_header removes all of the headers for the given header.
191
191
// For clients this is done on the request headers, for servers its the
@@ -205,7 +205,7 @@ NNG_DECL void nng_http_set_body(nng_http *, void *, size_t);
205
205
206
206
// nng_http_copy_body sets the body to send out in the next exchange, but
207
207
// makes a local copy. It can fail due to NNG_ENOMEM.
208
- NNG_DECL int nng_http_copy_body (nng_http * , const void * , size_t );
208
+ NNG_DECL nng_err nng_http_copy_body (nng_http * , const void * , size_t );
209
209
210
210
// nng_http_handler is a handler used on the server side to handle HTTP
211
211
// requests coming into a specific URL.
@@ -230,7 +230,7 @@ typedef struct nng_http_handler nng_http_handler;
230
230
// completion by nng_aio_finish. The second argument to this function is the
231
231
// handler data that was optionally set by nng_handler_set_data.
232
232
typedef void (* nng_http_handler_func )(nng_http * , void * , nng_aio * );
233
- NNG_DECL int nng_http_handler_alloc (
233
+ NNG_DECL nng_err nng_http_handler_alloc (
234
234
nng_http_handler * * , const char * , nng_http_handler_func );
235
235
236
236
// nng_http_handler_free frees the handler. This actually just drops a
@@ -241,19 +241,19 @@ NNG_DECL void nng_http_handler_free(nng_http_handler *);
241
241
// nng_http_handler_alloc_file creates a "file" based handler, that
242
242
// serves up static content from the given file path. The content-type
243
243
// supplied is determined from the file name using a simple built-in map.
244
- NNG_DECL int nng_http_handler_alloc_file (
244
+ NNG_DECL nng_err nng_http_handler_alloc_file (
245
245
nng_http_handler * * , const char * , const char * );
246
246
247
247
// nng_http_handler_alloc_static creates a static-content handler.
248
248
// The last argument is the content-type, which may be NULL (in which case
249
249
// "application/octet-stream" is assumed.)
250
- NNG_DECL int nng_http_handler_alloc_static (
250
+ NNG_DECL nng_err nng_http_handler_alloc_static (
251
251
nng_http_handler * * , const char * , const void * , size_t , const char * );
252
252
253
253
// nng_http_handler_alloc_redirect creates an HTTP redirect handler.
254
254
// The status is given, along with the new URL. If the status is 0,
255
255
// then 301 will be used instead.
256
- NNG_DECL int nng_http_handler_alloc_redirect (
256
+ NNG_DECL nng_err nng_http_handler_alloc_redirect (
257
257
nng_http_handler * * , const char * , uint16_t , const char * );
258
258
259
259
// nng_http_handler_alloc_file creates a "directory" based handler, that
@@ -262,7 +262,7 @@ NNG_DECL int nng_http_handler_alloc_redirect(
262
262
// directory content, otherwise a suitable error page is returned (the server
263
263
// does not generate index pages automatically.) The content-type for
264
264
// files is determined from the file name using a simple built-in map.
265
- NNG_DECL int nng_http_handler_alloc_directory (
265
+ NNG_DECL nng_err nng_http_handler_alloc_directory (
266
266
nng_http_handler * * , const char * , const char * );
267
267
268
268
// nng_http_handler_set_method sets the method that the handler will be
@@ -310,7 +310,7 @@ typedef struct nng_http_server nng_http_server;
310
310
// from the URL. If a server already exists, then a hold is placed on it, and
311
311
// that instance is returned. If no such server exists, then a new instance
312
312
// is created.
313
- NNG_DECL int nng_http_server_hold (nng_http_server * * , const nng_url * );
313
+ NNG_DECL nng_err nng_http_server_hold (nng_http_server * * , const nng_url * );
314
314
315
315
// nng_http_server_release releases the hold on the server. If this is the
316
316
// last instance of the server, then it is shutdown and resources are freed.
@@ -319,7 +319,7 @@ NNG_DECL void nng_http_server_release(nng_http_server *);
319
319
// nng_http_server_start starts the server handling HTTP. Once this is
320
320
// called, it will not be possible to change certain parameters (such as
321
321
// any TLS configuration).
322
- NNG_DECL int nng_http_server_start (nng_http_server * );
322
+ NNG_DECL nng_err nng_http_server_start (nng_http_server * );
323
323
324
324
// nng_http_server_stop stops the server. No new client connections are
325
325
// accepted after this returns. Once a server is stopped fully, the
@@ -331,14 +331,14 @@ NNG_DECL void nng_http_server_stop(nng_http_server *);
331
331
// This function will return NNG_EADDRINUSE if a conflicting handler
332
332
// is already registered (i.e. a handler with the same value for Host,
333
333
// Method, and URL.)
334
- NNG_DECL int nng_http_server_add_handler (
334
+ NNG_DECL nng_err nng_http_server_add_handler (
335
335
nng_http_server * , nng_http_handler * );
336
336
337
337
// nni_http_del_handler removes the given handler. The caller is
338
338
// responsible for finalizing it afterwards. If the handler was not found
339
339
// (not registered), NNG_ENOENT is returned. In this case it is unsafe
340
340
// to make assumptions about the validity of the handler.
341
- NNG_DECL int nng_http_server_del_handler (
341
+ NNG_DECL nng_err nng_http_server_del_handler (
342
342
nng_http_server * , nng_http_handler * );
343
343
344
344
// nng_http_server_set_tls adds a TLS configuration to the server,
@@ -347,36 +347,36 @@ NNG_DECL int nng_http_server_del_handler(
347
347
// server client, so the caller must have configured it reasonably.
348
348
// This API is not recommended unless the caller needs complete control
349
349
// over the TLS configuration.
350
- NNG_DECL int nng_http_server_set_tls (nng_http_server * , nng_tls_config * );
350
+ NNG_DECL nng_err nng_http_server_set_tls (nng_http_server * , nng_tls_config * );
351
351
352
352
// nng_http_server_get_tls obtains the TLS configuration if one is present,
353
353
// or returns NNG_EINVAL. The TLS configuration is invalidated if the
354
354
// nng_http_server_set_tls function is called, so be careful.
355
- NNG_DECL int nng_http_server_get_tls (nng_http_server * , nng_tls_config * * );
355
+ NNG_DECL nng_err nng_http_server_get_tls (nng_http_server * , nng_tls_config * * );
356
356
357
357
// nng_http_server_get_addr obtains the address with which the server was
358
358
// initialized or returns NNG_EINVAL. Useful for instance when the port has
359
359
// been automatically assigned.
360
- NNG_DECL int nng_http_server_get_addr (nng_http_server * , nng_sockaddr * );
360
+ NNG_DECL nng_err nng_http_server_get_addr (nng_http_server * , nng_sockaddr * );
361
361
362
362
// nng_http_server_set_error_page sets a custom error page (HTML) content
363
363
// to be sent for the given error code. This is used when the error is
364
364
// generated internally by the framework.
365
- NNG_DECL int nng_http_server_set_error_page (
365
+ NNG_DECL nng_err nng_http_server_set_error_page (
366
366
nng_http_server * , uint16_t , const char * );
367
367
368
368
// nng_http_server_set_error_file works like nng_http_server_error_page,
369
369
// except that the content is loaded from the named file path. The contents
370
370
// are loaded at the time this function is called, so this function should be
371
371
// called anytime the contents of the named file have changed.
372
- NNG_DECL int nng_http_server_set_error_file (
372
+ NNG_DECL nng_err nng_http_server_set_error_file (
373
373
nng_http_server * , uint16_t , const char * );
374
374
375
- // nng_http_server_res_error takes replaces the body of the response with
375
+ // nng_http_server_error takes replaces the body of the response with
376
376
// a custom error page previously set for the server, using the status
377
377
// of the response. The response must have the status set first using
378
378
// nng_http_res_set_status.
379
- NNG_DECL int nng_http_server_error (nng_http_server * , nng_http * );
379
+ NNG_DECL nng_err nng_http_server_error (nng_http_server * , nng_http * );
380
380
381
381
// nng_http_hijack is intended to be called by a handler that wishes to
382
382
// take over the processing of the HTTP session -- usually to change protocols
@@ -389,7 +389,7 @@ NNG_DECL int nng_http_server_error(nng_http_server *, nng_http *);
389
389
// of the request structure. (Some hijackers may keep the request for
390
390
// further processing.)
391
391
392
- NNG_DECL int nng_http_hijack (nng_http * );
392
+ NNG_DECL nng_err nng_http_hijack (nng_http * );
393
393
394
394
// nng_http_client represents a "client" object. Clients can be used
395
395
// to create HTTP connections. At present, connections are not cached
@@ -398,7 +398,7 @@ typedef struct nng_http_client nng_http_client;
398
398
399
399
// nng_http_client_alloc allocates a client object, associated with
400
400
// the given URL.
401
- NNG_DECL int nng_http_client_alloc (nng_http_client * * , const nng_url * );
401
+ NNG_DECL nng_err nng_http_client_alloc (nng_http_client * * , const nng_url * );
402
402
403
403
// nng_http_client_free frees the client. Connections created by the
404
404
// the client are not necessarily closed.
@@ -408,12 +408,12 @@ NNG_DECL void nng_http_client_free(nng_http_client *);
408
408
// the entire TLS configuration on the client, so the caller must have
409
409
// configured it reasonably. This API is not recommended unless the
410
410
// caller needs complete control over the TLS configuration.
411
- NNG_DECL int nng_http_client_set_tls (nng_http_client * , nng_tls_config * );
411
+ NNG_DECL nng_err nng_http_client_set_tls (nng_http_client * , nng_tls_config * );
412
412
413
413
// nng_http_client_get_tls obtains the TLS configuration if one is present,
414
414
// or returns NNG_EINVAL. The supplied TLS configuration object may
415
415
// be invalidated by any future calls to nni_http_client_set_tls.
416
- NNG_DECL int nng_http_client_get_tls (nng_http_client * , nng_tls_config * * );
416
+ NNG_DECL nng_err nng_http_client_get_tls (nng_http_client * , nng_tls_config * * );
417
417
418
418
// nng_http_client_connect establishes a new connection with the server
419
419
// named in the URL used when the client was created. Once the connection
0 commit comments