Changeset 73334 in vbox for trunk/src/VBox/Runtime/generic/http-curl.cpp
- Timestamp:
- Jul 23, 2018 4:52:04 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/generic/http-curl.cpp
r70141 r73334 126 126 /** @} */ 127 127 128 /** @name Cached settings. 129 * @{ */ 130 /** Maximum number of redirects to follow. 131 * Zero if not automatically following (default). */ 132 uint32_t cMaxRedirects; 133 /** @} */ 134 128 135 /** Abort the current HTTP request if true. */ 129 136 bool volatile fAbort; … … 273 280 pThis->pCurl = pCurl; 274 281 pThis->fUseSystemProxySettings = true; 282 pThis->cMaxRedirects = 0; /* no automatic redir following */ 275 283 276 284 *phHttp = (RTHTTP)pThis; … … 1825 1833 1826 1834 1835 RTR3DECL(int) RTHttpSetFollowRedirects(RTHTTP hHttp, uint32_t cMaxRedirects) 1836 { 1837 PRTHTTPINTERNAL pThis = hHttp; 1838 RTHTTP_VALID_RETURN(pThis); 1839 AssertReturn(!pThis->fBusy, VERR_WRONG_ORDER); 1840 1841 /* 1842 * Update the redirection settings. 1843 */ 1844 if (pThis->cMaxRedirects != cMaxRedirects) 1845 { 1846 int rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_MAXREDIRS, (long)cMaxRedirects); 1847 AssertMsgReturn(rcCurl == CURLE_OK, ("CURLOPT_MAXREDIRS=%u: %d (%#x)\n", cMaxRedirects, rcCurl, rcCurl), 1848 VERR_HTTP_CURL_ERROR); 1849 1850 rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_FOLLOWLOCATION, (long)(cMaxRedirects > 0)); 1851 AssertMsgReturn(rcCurl == CURLE_OK, ("CURLOPT_FOLLOWLOCATION=%d: %d (%#x)\n", cMaxRedirects > 0, rcCurl, rcCurl), 1852 VERR_HTTP_CURL_ERROR); 1853 1854 pThis->cMaxRedirects = cMaxRedirects; 1855 } 1856 return VINF_SUCCESS; 1857 } 1858 1859 1827 1860 RTR3DECL(int) RTHttpSetHeaders(RTHTTP hHttp, size_t cHeaders, const char * const *papszHeaders) 1828 1861 { … … 2049 2082 rc = VINF_SUCCESS; 2050 2083 break; 2051 case 301: 2084 case 301: /* Moved permantently. */ 2085 case 302: /* Found / Moved temporarily. */ 2086 case 303: /* See Other. */ 2087 case 307: /* Temporary redirect. */ 2088 case 308: /* Permanent redirect. */ 2052 2089 { 2053 const char *pszRedirect ;2090 const char *pszRedirect = NULL; 2054 2091 curl_easy_getinfo(pThis->pCurl, CURLINFO_REDIRECT_URL, &pszRedirect); 2055 size_t cb = strlen(pszRedirect);2092 size_t cb = pszRedirect ? strlen(pszRedirect) : 0; 2056 2093 if (cb > 0 && cb < 2048) 2057 2094 pThis->pszRedirLocation = RTStrDup(pszRedirect);
Note:
See TracChangeset
for help on using the changeset viewer.