Changeset 51704 in vbox for trunk/src/VBox/Runtime/common/misc/http.cpp
- Timestamp:
- Jun 24, 2014 11:06:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/http.cpp
r51635 r51704 50 50 typedef struct RTHTTPINTERNAL 51 51 { 52 /** magic value */ 53 uint32_t u32Magic; 54 /** cURL handle */ 55 CURL *pCurl; 56 long lLastResp; 52 /** Magic value. */ 53 uint32_t u32Magic; 54 /** cURL handle. */ 55 CURL *pCurl; 56 /** The last response code. */ 57 long lLastResp; 57 58 /** custom headers */ 58 struct curl_slist *pHeaders; 59 /** CA certificate for HTTPS authentication check */ 60 char *pcszCAFile; 61 /** abort the current HTTP request if true */ 62 bool fAbort; 59 struct curl_slist *pHeaders; 60 /** CA certificate for HTTPS authentication check. */ 61 char *pcszCAFile; 62 /** Abort the current HTTP request if true. */ 63 bool fAbort; 64 /** The location field for 301 responses. */ 65 char *pszRedirLocation; 63 66 } RTHTTPINTERNAL; 64 67 typedef RTHTTPINTERNAL *PRTHTTPINTERNAL; … … 136 139 RTStrFree(pHttpInt->pcszCAFile); 137 140 141 if (pHttpInt->pszRedirLocation) 142 RTStrFree(pHttpInt->pszRedirLocation); 143 138 144 RTMemFree(pHttpInt); 139 145 … … 172 178 pHttpInt->fAbort = true; 173 179 180 return VINF_SUCCESS; 181 } 182 183 RTR3DECL(int) RTHttpGetRedirLocation(RTHTTP hHttp, char **ppszRedirLocation) 184 { 185 PRTHTTPINTERNAL pHttpInt = hHttp; 186 RTHTTP_VALID_RETURN(pHttpInt); 187 188 if (!pHttpInt->pszRedirLocation) 189 return VERR_HTTP_NOT_FOUND; 190 191 *ppszRedirLocation = RTStrDup(pHttpInt->pszRedirLocation); 174 192 return VINF_SUCCESS; 175 193 } … … 354 372 { 355 373 int rc = VERR_INTERNAL_ERROR; 374 375 if (pHttpInt->pszRedirLocation) 376 { 377 RTStrFree(pHttpInt->pszRedirLocation); 378 pHttpInt->pszRedirLocation = NULL; 379 } 356 380 if (rcCurl == CURLE_OK) 357 381 { … … 365 389 rc = VINF_SUCCESS; 366 390 break; 391 case 301: 392 { 393 const char *pszRedirect; 394 curl_easy_getinfo(pHttpInt->pCurl, CURLINFO_REDIRECT_URL, &pszRedirect); 395 size_t cb = strlen(pszRedirect); 396 if (cb > 0 && cb < 4096) 397 pHttpInt->pszRedirLocation = RTStrDup(pszRedirect); 398 rc = VERR_HTTP_REDIRECTED; 399 break; 400 } 367 401 case 400: 368 402 /* bad request */
Note:
See TracChangeset
for help on using the changeset viewer.