aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/http/http_msg.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-06-12 09:09:39 -0700
committerGarrett D'Amore <garrett@damore.org>2018-06-12 09:09:39 -0700
commit79c761b66276289ebe703b596e285469deaa7a16 (patch)
tree98c98edc63bf4af45ab727dc7aa087c65d274f7f /src/supplemental/http/http_msg.c
parente60308808f58a3517170edf61245031cb899e59e (diff)
downloadnng-79c761b66276289ebe703b596e285469deaa7a16.tar.gz
nng-79c761b66276289ebe703b596e285469deaa7a16.tar.bz2
nng-79c761b66276289ebe703b596e285469deaa7a16.zip
fixes #527 http_res_set_reason crash in example
Diffstat (limited to 'src/supplemental/http/http_msg.c')
-rw-r--r--src/supplemental/http/http_msg.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/supplemental/http/http_msg.c b/src/supplemental/http/http_msg.c
index d4744471..bc51e408 100644
--- a/src/supplemental/http/http_msg.c
+++ b/src/supplemental/http/http_msg.c
@@ -660,7 +660,7 @@ nni_http_res_get_version(nni_http_res *res)
int
nni_http_req_set_version(nni_http_req *req, const char *vers)
{
- if (strcmp(vers, "HTTP/1.1") == 0) {
+ if ((vers != NULL) && (strcmp(vers, "HTTP/1.1") == 0)) {
vers = NULL;
}
return (http_set_string(&req->vers, vers));
@@ -669,7 +669,7 @@ nni_http_req_set_version(nni_http_req *req, const char *vers)
int
nni_http_res_set_version(nni_http_res *res, const char *vers)
{
- if (strcmp(vers, "HTTP/1.1") == 0) {
+ if ((vers != NULL) && (strcmp(vers, "HTTP/1.1") == 0)) {
vers = NULL;
}
return (http_set_string(&res->vers, vers));
@@ -684,7 +684,7 @@ nni_http_req_set_uri(nni_http_req *req, const char *uri)
int
nni_http_req_set_method(nni_http_req *req, const char *meth)
{
- if (strcmp(meth, "GET") == 0) {
+ if ((meth != NULL) && (strcmp(meth, "GET") == 0)) {
meth = NULL;
}
return (http_set_string(&req->meth, meth));
@@ -981,7 +981,8 @@ nni_http_res_get_reason(nni_http_res *res)
int
nni_http_res_set_reason(nni_http_res *res, const char *reason)
{
- if (strcmp(reason, http_reason(res->code)) == 0) {
+ if ((reason != NULL) &&
+ (strcmp(reason, http_reason(res->code)) == 0)) {
reason = NULL;
}
return (http_set_string(&res->rsn, reason));