-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
54 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright 2020 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2024 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2018 Capitar IT Group BV <[email protected]> | ||
// Copyright 2020 Dirac Research <[email protected]> | ||
// | ||
|
@@ -22,7 +22,7 @@ extern "C" { | |
|
||
#include <stdint.h> | ||
|
||
struct nng_tls_config; | ||
#include <nng/nng.h> | ||
|
||
// HTTP status codes. This list is not exhaustive. | ||
enum nng_http_status { | ||
|
@@ -101,14 +101,14 @@ NNG_DECL int nng_http_req_alloc(nng_http_req **, const nng_url *); | |
NNG_DECL void nng_http_req_free(nng_http_req *); | ||
|
||
// nng_http_req_get_method returns the method. | ||
NNG_DECL const char *nng_http_req_get_method(nng_http_req *); | ||
NNG_DECL const char *nng_http_req_get_method(const nng_http_req *); | ||
|
||
// nng_http_req_get_version returns the version, usually HTTP/1.1. | ||
NNG_DECL const char *nng_http_req_get_version(nng_http_req *); | ||
NNG_DECL const char *nng_http_req_get_version(const nng_http_req *); | ||
|
||
// nng_http_req_get_uri returns the "abs-uri", which is URL without | ||
// the scheme, host, or port. | ||
NNG_DECL const char *nng_http_req_get_uri(nng_http_req *); | ||
NNG_DECL const char *nng_http_req_get_uri(const nng_http_req *); | ||
|
||
// nng_http_req_set_header sets an HTTP header, replacing any previous value | ||
// that might have been present. | ||
|
@@ -125,7 +125,8 @@ NNG_DECL int nng_http_req_del_header(nng_http_req *, const char *); | |
|
||
// nng_http_req_get_header looks up a header with the named, returns NULL | ||
// if not found. | ||
NNG_DECL const char *nng_http_req_get_header(nng_http_req *, const char *); | ||
NNG_DECL const char *nng_http_req_get_header( | ||
const nng_http_req *, const char *); | ||
|
||
// nng_http_req_set_method is used to change the method of a request. | ||
// The method should be an upper case HTTP method, like POST, or DELETE. | ||
|
@@ -174,14 +175,14 @@ NNG_DECL int nng_http_res_alloc_error(nng_http_res **, uint16_t); | |
NNG_DECL void nng_http_res_free(nng_http_res *); | ||
|
||
// nng_http_res_get_status returns the HTTP status code from the server. | ||
NNG_DECL uint16_t nng_http_res_get_status(nng_http_res *); | ||
NNG_DECL uint16_t nng_http_res_get_status(const nng_http_res *); | ||
|
||
// nng_http_res_set_status sets the HTTP status code. | ||
NNG_DECL int nng_http_res_set_status(nng_http_res *, uint16_t); | ||
|
||
// nng_http_res_get_reason returns the human readable status message | ||
// that the server responds (or responded) with. | ||
NNG_DECL const char *nng_http_res_get_reason(nng_http_res *); | ||
NNG_DECL const char *nng_http_res_get_reason(const nng_http_res *); | ||
|
||
// nng_http_res_set_reason sets the human readable status message. | ||
// NULL means that a default reason is used based on the status code. | ||
|
@@ -202,15 +203,16 @@ NNG_DECL int nng_http_res_del_header(nng_http_res *, const char *); | |
|
||
// nng_http_res_get_header looks up a header with the named, returns NULL | ||
// if not found. | ||
NNG_DECL const char *nng_http_res_get_header(nng_http_res *, const char *); | ||
NNG_DECL const char *nng_http_res_get_header( | ||
const nng_http_res *, const char *); | ||
|
||
// nng_http_res_set_version is used to change the version of a response. | ||
// Normally the version is "HTTP/1.1". Note that the framework does | ||
// not support HTTP/2 at all. NULL sets the default ("HTTP/1.1"). | ||
NNG_DECL int nng_http_res_set_version(nng_http_res *, const char *); | ||
|
||
// nng_http_res_get_version returns the version, usually HTTP/1.1. | ||
NNG_DECL const char *nng_http_res_get_version(nng_http_res *); | ||
NNG_DECL const char *nng_http_res_get_version(const nng_http_res *); | ||
|
||
// nng_http_res_get_data gets the data for the response. | ||
NNG_DECL void nng_http_res_get_data(nng_http_res *, void **, size_t *); | ||
|
@@ -437,14 +439,12 @@ NNG_DECL int nng_http_server_del_handler( | |
// server 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_server_set_tls( | ||
nng_http_server *, struct nng_tls_config *); | ||
NNG_DECL int nng_http_server_set_tls(nng_http_server *, nng_tls_config *); | ||
|
||
// nng_http_server_get_tls obtains the TLS configuration if one is present, | ||
// or returns NNG_EINVAL. The TLS configuration is invalidated if the | ||
// nng_http_server_set_tls function is called, so be careful. | ||
NNG_DECL int nng_http_server_get_tls( | ||
nng_http_server *, struct nng_tls_config **); | ||
NNG_DECL int nng_http_server_get_tls(nng_http_server *, nng_tls_config **); | ||
|
||
// nng_http_server_get_addr obtains the address with which the server was | ||
// initialized or returns NNG_EINVAL. Useful for instance when the port has | ||
|
@@ -504,14 +504,12 @@ NNG_DECL void nng_http_client_free(nng_http_client *); | |
// 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 *, struct nng_tls_config *); | ||
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 *, struct nng_tls_config **); | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// Copyright 2019 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2024 Staysail Systems, Inc. <[email protected]> | ||
// Copyright 2018 Capitar IT Group BV <[email protected]> | ||
// | ||
// This software is supplied under the terms of the MIT License, a | ||
|
@@ -262,7 +262,7 @@ nni_http_res_add_header(nni_http_res *res, const char *key, const char *val) | |
} | ||
|
||
static const char * | ||
http_get_header(nni_list *hdrs, const char *key) | ||
http_get_header(const nni_list *hdrs, const char *key) | ||
{ | ||
http_header *h; | ||
NNI_LIST_FOREACH (hdrs, h) { | ||
|
@@ -274,13 +274,13 @@ http_get_header(nni_list *hdrs, const char *key) | |
} | ||
|
||
const char * | ||
nni_http_req_get_header(nni_http_req *req, const char *key) | ||
nni_http_req_get_header(const nni_http_req *req, const char *key) | ||
{ | ||
return (http_get_header(&req->hdrs, key)); | ||
} | ||
|
||
const char * | ||
nni_http_res_get_header(nni_http_res *res, const char *key) | ||
nni_http_res_get_header(const nni_http_res *res, const char *key) | ||
{ | ||
return (http_get_header(&res->hdrs, key)); | ||
} | ||
|
@@ -672,25 +672,25 @@ nni_http_res_alloc(nni_http_res **resp) | |
} | ||
|
||
const char * | ||
nni_http_req_get_method(nni_http_req *req) | ||
nni_http_req_get_method(const nni_http_req *req) | ||
{ | ||
return (req->meth != NULL ? req->meth : "GET"); | ||
} | ||
|
||
const char * | ||
nni_http_req_get_uri(nni_http_req *req) | ||
nni_http_req_get_uri(const nni_http_req *req) | ||
{ | ||
return (req->uri != NULL ? req->uri : ""); | ||
} | ||
|
||
const char * | ||
nni_http_req_get_version(nni_http_req *req) | ||
nni_http_req_get_version(const nni_http_req *req) | ||
{ | ||
return (req->vers != NULL ? req->vers : "HTTP/1.1"); | ||
} | ||
|
||
const char * | ||
nni_http_res_get_version(nni_http_res *res) | ||
nni_http_res_get_version(const nni_http_res *res) | ||
{ | ||
return (res->vers != NULL ? res->vers : "HTTP/1.1"); | ||
} | ||
|
@@ -736,7 +736,7 @@ nni_http_res_set_status(nni_http_res *res, uint16_t status) | |
} | ||
|
||
uint16_t | ||
nni_http_res_get_status(nni_http_res *res) | ||
nni_http_res_get_status(const nni_http_res *res) | ||
{ | ||
return (res->code); | ||
} | ||
|
@@ -1011,7 +1011,7 @@ nni_http_reason(uint16_t code) | |
} | ||
|
||
const char * | ||
nni_http_res_get_reason(nni_http_res *res) | ||
nni_http_res_get_reason(const nni_http_res *res) | ||
{ | ||
return (res->rsn ? res->rsn : nni_http_reason(res->code)); | ||
} | ||
|
Oops, something went wrong.