diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-10-04 01:11:54 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-10-04 01:11:54 +0000 |
commit | b3fd2f88cb9a493c43d612bbc58713b50a93bd1b (patch) | |
tree | 6fa19479a976df16dacae1c3ba8b5ac7c48c0ba1 /pjlib-util | |
parent | 2d607c9fcd1a5ca1c6920d7ce7748cae497ad77f (diff) |
Another fix for authentication in HTTP client (re #1136):
- missing opaque parameter in the response
- also replaced "\n" with "\r\n"
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3333 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib-util')
-rw-r--r-- | pjlib-util/src/pjlib-util/http_client.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/pjlib-util/src/pjlib-util/http_client.c b/pjlib-util/src/pjlib-util/http_client.c index 2e966387..94f9ba7a 100644 --- a/pjlib-util/src/pjlib-util/http_client.c +++ b/pjlib-util/src/pjlib-util/http_client.c @@ -1304,6 +1304,7 @@ static pj_status_t auth_respond_digest(pj_http_req *hreq) 12 + /* qop=auth */ 8 + /* nc=.. */ 30 + /* cnonce= */ + 12 + chal->opaque.slen + /* opaque=".." */ 0; phdr->value.ptr = (char*)pj_pool_alloc(hreq->pool, len); @@ -1375,6 +1376,12 @@ static pj_status_t auth_respond_digest(pj_http_req *hreq) return PJ_ETOOSMALL; phdr->value.slen = len; + if (chal->opaque.slen) { + pj_strcat2(&phdr->value, ", opaque=\""); + pj_strcat(&phdr->value, &chal->opaque); + pj_strcat2(&phdr->value, "\""); + } + } else { /* Server requires quality protection that we don't support. */ TRACE_((THIS_FILE, "Error: Unsupported qop offer %.*s", @@ -1474,13 +1481,13 @@ static pj_status_t http_req_start_sending(pj_http_req *hreq) pj_strassign(&pkt, &hreq->buffer); pkt.slen = 0; /* Start-line */ - str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "%.*s %.*s %s/%.*s\n", + str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "%.*s %.*s %s/%.*s\r\n", STR_PREC(hreq->param.method), STR_PREC(hreq->hurl.path), get_protocol(&hreq->hurl.protocol), STR_PREC(hreq->param.version)); /* Header field "Host" */ - str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "Host: %.*s:%d\n", + str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "Host: %.*s:%d\r\n", STR_PREC(hreq->hurl.host), hreq->hurl.port); if (!pj_strcmp2(&hreq->param.method, http_method_names[HTTP_PUT])) { char buf[16]; @@ -1489,13 +1496,13 @@ static pj_status_t http_req_start_sending(pj_http_req *hreq) pj_utoa(hreq->param.reqdata.total_size ? hreq->param.reqdata.total_size: hreq->param.reqdata.size, buf); - str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "%s: %s\n", + str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "%s: %s\r\n", CONTENT_LENGTH, buf); } /* Append user-specified headers */ for (i = 0; i < hreq->param.headers.count; i++) { - str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "%.*s: %.*s\n", + str_snprintf(&pkt, BUF_SIZE, PJ_TRUE, "%.*s: %.*s\r\n", STR_PREC(hreq->param.headers.header[i].name), STR_PREC(hreq->param.headers.header[i].value)); } @@ -1504,7 +1511,7 @@ static pj_status_t http_req_start_sending(pj_http_req *hreq) goto on_return; } - pj_strcat2(&pkt, "\n"); + pj_strcat2(&pkt, "\r\n"); pkt.ptr[pkt.slen] = 0; TRACE_((THIS_FILE, "%s", pkt.ptr)); } else { |