Changeset 3332 for pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c
- Timestamp:
- Oct 1, 2010 6:43:17 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c
r3321 r3332 767 767 } 768 768 769 /* Get the location of '@' character to indicate the end of 770 * user:passwd part of an URI. If user:passwd part is not 771 * present, NULL will be returned. 772 */ 773 static char *get_url_at_pos(const char *str, long len) 774 { 775 const char *end = str + len; 776 const char *p = str; 777 778 /* skip scheme: */ 779 while (p!=end && *p!='/') ++p; 780 if (p!=end && *p=='/') ++p; 781 if (p!=end && *p=='/') ++p; 782 if (p==end) return NULL; 783 784 for (; p!=end; ++p) { 785 switch (*p) { 786 case '/': 787 return NULL; 788 case '@': 789 return (char*)p; 790 } 791 } 792 793 return NULL; 794 } 795 796 769 797 PJ_DEF(pj_status_t) pj_http_req_parse_url(const pj_str_t *url, 770 798 pj_http_url *hurl) … … 802 830 pj_scan_advance_n(&scanner, 3, PJ_FALSE); 803 831 804 if ( pj_memchr(url->ptr, '@', url->slen)) {832 if (get_url_at_pos(url->ptr, url->slen)) { 805 833 /* Parse username and password */ 806 834 pj_scan_get_until_chr(&scanner, ":@", &hurl->username); … … 925 953 * remove them from the URL. 926 954 */ 927 if ((at_pos= pj_strchr(&hreq->url, '@')) != NULL) {955 if ((at_pos=get_url_at_pos(hreq->url.ptr, hreq->url.slen)) != NULL) { 928 956 pj_str_t tmp; 929 957 char *user_pos = pj_strchr(&hreq->url, '/');
Note: See TracChangeset
for help on using the changeset viewer.