MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / openHttpFile

Function openHttpFile

cmake/Windows/Contrib/Inetc/inetc.cpp:639–827  ·  view source on GitHub ↗

* FUNCTION NAME: openHttpFile() * PURPOSE: * file open, size request, re-get lseek * SPECIAL CONSIDERATIONS: * *****************************************************/

Source from the content-addressed store, hash-verified

637*
638*****************************************************/
639HINTERNET openHttpFile(HINTERNET hConn, INTERNET_SCHEME nScheme, TCHAR *path)
640{
641 TCHAR buf[256] = TEXT("");
642 HINTERNET hFile;
643 DWORD rslt, err;
644 bool first_attempt = true;;
645
646// test connection for PUT, the only way to do this before sending data
647// OPTIONS fails on HttpOpenRequest step for HTTPS
648// but works for HEAD I guess
649 if(fput)// && nScheme != INTERNET_SCHEME_HTTPS)
650 {
651// old proxy's may not support OPTIONS request, so changed to HEAD....
652 if((hFile = HttpOpenRequest(hConn, TEXT("HEAD"), path, NULL, NULL, NULL,
653// if((hFile = HttpOpenRequest(hConn, TEXT("OPTIONS"), path, NULL, NULL, NULL,
654 INTERNET_FLAG_RELOAD | INTERNET_FLAG_KEEP_CONNECTION |
655 (nocookies ? (INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES) : 0), 0)) != NULL)
656 {
657 if(*szAuth)
658 {
659 wsprintf(buf, PROXY_AUTH_HDR, szAuth);
660 HttpAddRequestHeaders(hFile, buf, -1,
661 HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
662 }
663resend_proxy1:
664 if(*szBasic)
665 {
666 wsprintf(buf, HOST_AUTH_HDR, szBasic);
667 HttpAddRequestHeaders(hFile, buf, -1,
668 HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
669 }
670resend_auth1:
671 if(HttpSendRequest(hFile, NULL, 0, NULL, 0))
672 {
673 queryStatus(hFile);
674// may be don't need to read all from socket, but this looks safer
675 while(InternetReadFile(hFile, buf, sizeof(buf), &rslt) && rslt > 0) {}
676 if(!silent && (status == ERR_PROXY || status == ERR_AUTH))// || status == ERR_FORBIDDEN))
677 {
678 rslt = InternetErrorDlg(hDlg, hFile,
679 ERROR_INTERNET_INCORRECT_PASSWORD,
680 FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
681 FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
682 FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,
683 NULL);
684 if (rslt == ERROR_INTERNET_FORCE_RETRY)
685 {
686 status = ST_URLOPEN;
687 if(status == ERR_PROXY) goto resend_proxy1;
688 else goto resend_auth1;
689 }
690 else
691 {
692 status = ST_CANCELLED;
693 }
694
695 }
696 // no such file is OK for PUT. server first checks authentication

Callers 1

inetTransferFunction · 0.85

Calls 3

queryStatusFunction · 0.85
mySendRequestFunction · 0.85
myatouFunction · 0.85

Tested by

no test coverage detected