diff options
| author | Shu Li <[email protected]> | 2021-05-21 19:51:12 +0800 |
|---|---|---|
| committer | Shu Li <[email protected]> | 2021-05-21 19:51:12 +0800 |
| commit | e1f1765d82ca852b704d19d4b575267eb1d3a057 (patch) | |
| tree | 0287876502d0813d7095d10c682f1d98d4644327 /src/HTTP_Message_Region.c | |
| parent | a69f48f137d89d5c49d82adcd85d33f996143519 (diff) | |
支持URI可以不以'/'开始进行解析
Diffstat (limited to 'src/HTTP_Message_Region.c')
| -rw-r--r-- | src/HTTP_Message_Region.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/HTTP_Message_Region.c b/src/HTTP_Message_Region.c index f90bf35..4fa5aeb 100644 --- a/src/HTTP_Message_Region.c +++ b/src/HTTP_Message_Region.c @@ -121,10 +121,29 @@ uchar http_doWithHost(http_parser_t* a_http, http_stream *a_http_stream, char* v } } /*20190111 ����URI*/ - else if(a_http->url_buf!=NULL && a_http->url_buf[0]!='/') + else if(a_http->url_buf!=NULL && a_http->url_buflen>=strlen("http://") && 0==strncasecmp(a_http->url_buf, "http://", strlen("http://"))) { a_http->parser.is_ab_uri = 1; - } + } + /*URI=sample.html, do not start with '/'; then we add a '/' */ + else if(a_http->url_buf!=NULL && a_http->url_buf[0]!='/') + { + uri = (char*)dictator_malloc(thread_seq, a_http->url_buflen); + urilen = a_http->url_buflen; + memcpy(uri, a_http->url_buf, a_http->url_buflen); + if(a_http->url_buf!=NULL) dictator_free(thread_seq, a_http->url_buf); + a_http->url_buf = NULL; + a_http->url_buflen = valuelen+strlen("/")+urilen; + a_http->url_buf = (char*)dictator_malloc(thread_seq, a_http->url_buflen); + memcpy(a_http->url_buf, value, valuelen); + memcpy(a_http->url_buf+valuelen, "/", strlen("/")); + memcpy(a_http->url_buf+valuelen+strlen("/"), uri, urilen); + if(uri!=NULL) + { + dictator_free(thread_seq, uri); + uri = NULL; + } + } } a_http->parser.p_url = a_http->url_buf; @@ -263,7 +282,7 @@ uchar http_doWithContentRange(http_parser_t* a_http, http_stream *a_http_stream, /*only get digit*/ for(i=0;i<valuelen;i++) { - if( *(value+i)>='0' && *(value+i)<='9' || *(value+i)=='-') + if( (*(value+i)>='0' && *(value+i)<='9') || *(value+i)=='-') { digit = value+i; valuelen -= i; @@ -381,9 +400,9 @@ uchar http_outPutUrl(http_parser_t *a_http, struct streaminfo *a_tcp, int thread } } else - { + { a_http->parser.is_ab_uri = 1; - } + } a_http->parser.p_url = a_http->url_buf; a_http->parser.url_len = a_http->url_buflen; |
