aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/http
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-12-27 16:32:33 -0800
committerGarrett D'Amore <garrett@damore.org>2017-12-27 16:32:33 -0800
commit5ff3d3d3ab82be4b2171e06f1def9cdddaef4115 (patch)
tree028fff3d0dbcbec741406541931029c106bae465 /src/supplemental/http
parenteb1f8db4ed87867f0f08afba79253e3981db9c88 (diff)
downloadnng-5ff3d3d3ab82be4b2171e06f1def9cdddaef4115.tar.gz
nng-5ff3d3d3ab82be4b2171e06f1def9cdddaef4115.tar.bz2
nng-5ff3d3d3ab82be4b2171e06f1def9cdddaef4115.zip
fixes #180 add websocket header properties
Diffstat (limited to 'src/supplemental/http')
-rw-r--r--src/supplemental/http/http.h16
-rw-r--r--src/supplemental/http/http_msg.c26
2 files changed, 35 insertions, 7 deletions
diff --git a/src/supplemental/http/http.h b/src/supplemental/http/http.h
index b28845ec..3ecce4c8 100644
--- a/src/supplemental/http/http.h
+++ b/src/supplemental/http/http.h
@@ -45,7 +45,8 @@ extern const char *nni_http_req_get_header(nni_http_req *, const char *);
extern const char *nni_http_req_get_version(nni_http_req *);
extern const char *nni_http_req_get_uri(nni_http_req *);
extern const char *nni_http_req_get_method(nni_http_req *);
-extern int nni_http_req_parse(nni_http_req *, void *, size_t, size_t *);
+extern int nni_http_req_parse(nni_http_req *, void *, size_t, size_t *);
+extern char *nni_http_req_headers(nni_http_req *);
extern int nni_http_res_init(nni_http_res **);
extern void nni_http_res_fini(nni_http_res *);
@@ -60,12 +61,13 @@ extern const char *nni_http_res_get_header(nni_http_res *, const char *);
extern const char *nni_http_res_get_version(nni_http_res *);
extern const char *nni_http_res_get_reason(nni_http_res *);
extern int nni_http_res_get_status(nni_http_res *);
-extern int nni_http_res_parse(nni_http_res *, void *, size_t, size_t *);
-extern int nni_http_res_set_data(nni_http_res *, const void *, size_t);
-extern int nni_http_res_copy_data(nni_http_res *, const void *, size_t);
-extern int nni_http_res_alloc_data(nni_http_res *, size_t);
-extern void nni_http_res_get_data(nni_http_res *, void **, size_t *);
-extern int nni_http_res_init_error(nni_http_res **, uint16_t);
+extern int nni_http_res_parse(nni_http_res *, void *, size_t, size_t *);
+extern int nni_http_res_set_data(nni_http_res *, const void *, size_t);
+extern int nni_http_res_copy_data(nni_http_res *, const void *, size_t);
+extern int nni_http_res_alloc_data(nni_http_res *, size_t);
+extern void nni_http_res_get_data(nni_http_res *, void **, size_t *);
+extern int nni_http_res_init_error(nni_http_res **, uint16_t);
+extern char *nni_http_res_headers(nni_http_res *);
// HTTP status codes. This list is not exhaustive.
enum { NNI_HTTP_STATUS_CONTINUE = 100,
diff --git a/src/supplemental/http/http_msg.c b/src/supplemental/http/http_msg.c
index 2e245868..8b3c6a7c 100644
--- a/src/supplemental/http/http_msg.c
+++ b/src/supplemental/http/http_msg.c
@@ -520,6 +520,32 @@ http_res_prepare(nni_http_res *res)
return (rv);
}
+char *
+nni_http_req_headers(nni_http_req *req)
+{
+ char * s;
+ size_t len;
+
+ len = http_sprintf_headers(NULL, 0, &req->hdrs) + 1;
+ if ((s = nni_alloc(len)) != NULL) {
+ http_sprintf_headers(s, len, &req->hdrs);
+ }
+ return (s);
+}
+
+char *
+nni_http_res_headers(nni_http_res *res)
+{
+ char * s;
+ size_t len;
+
+ len = http_sprintf_headers(NULL, 0, &res->hdrs) + 1;
+ if ((s = nni_alloc(len)) != NULL) {
+ http_sprintf_headers(s, len, &res->hdrs);
+ }
+ return (s);
+}
+
int
nni_http_req_get_buf(nni_http_req *req, void **data, size_t *szp)
{