Hello
The error you are getting is 12152 ERROR_HTTP_INVALID_SERVER_RESPONSE
The server response could not be parsed.
You should get a network trace and WinINet log to see what return data is
causing this error.
884931 How to use the debug version of the Wininet.dll file for Internet
http://support.microsoft.com/?id=884931
Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Thread-Topic: problems with HttpSendRequest
| thread-index: AcT0g9q1dqAWpcSOTCSmpE23TbRkwQ==
| X-WBNR-Posting-Host: 24.6.43.144
| From: "=?Utf-8?B?TWFoZXNoX3A=?=" <***@yahoo.com>
| References: <#***@TK2MSFTNGP11.phx.gbl>
<***@cpmsftngxa10.phx.gbl>
| Subject: RE: problems with HttpSendRequest
| Date: Thu, 6 Jan 2005 22:41:02 -0800
| Lines: 263
| Message-ID: <7EC7503F-3BBD-4762-A174-***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11971
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| I tried starting a new thread but for some reason I can't do that. So I
am
| just using this already exising thread to do that.
|
| I am having a inproc activeX control from which I am trying to POST a
file to
| a server using HTTPS connection w/ multi-part header through ISA 2004
proxy
| server. I am using HttpSendRequestEx(), InternetWriteFile() and
| HttpEndRequest() to upload the file. But HttpEndRequest() always fails on
| Windows 2000 IE 6.0 SP1 w/ error code 12152.
|
| This activeX control is called from a webpage which is also accessing
HTTPS
| pages on the server.
|
| Also, on Windows XP SP2, I have to set the proxy user name and password
| using InternetSetOptions() or else it fails too.
|
| The file uploaded without any problems if done directly without proxy
| Has anyone got into this problem?
|
| Here is the the psudo code which does this :
| ***********************************************************
| int PostData()
| {
| bool bSuccess = FALSE;
| HINTERNET hInternet = InternetOpenA(
| "Post Data",
| INTERNET_OPEN_TYPE_PRECONFIG,
| NULL,
| NULL,
| 0
| );
|
| if (!hInternet )
| {
| return FALSE;
| }
|
| DWORD dwService = INTERNET_SERVICE_HTTP;
| DWORD dwFlags = NULL;
| DWORD dwContext = 0; //synchronous transfer
|
| HINTERNET hConnection = InternetConnectA(hInternet,
| m_lpszURL, (INTERNET_PORT)m_ulPort,
| NULL,NULL,
| dwService,dwFlags,
| dwContext);
|
| if ( !hConnection )
| {
| InternetCloseHandle(hInternet);
| return TRUE;
| }
|
|
| CHAR* ppszAccept[2]={"*/*",0};
|
| dwFlags = INTERNET_FLAG_RELOAD |
| INTERNET_FLAG_NO_CACHE_WRITE |
| INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP |
| INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |
| INTERNET_FLAG_IGNORE_CERT_DATE_INVALID |
| INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
| INTERNET_FLAG_KEEP_CONNECTION;
|
| if (m_ulPort == INTERNET_DEFAULT_HTTPS_PORT)
| dwFlags |= INTERNET_FLAG_SECURE;
|
|
| HINTERNET hRequest = HttpOpenRequestA(hConnection,
| "POST",
| "\uploadurl",
| NULL,
| NULL,
| (LPCSTR *)ppszAccept,
| dwFlags,
| NULL
| );
|
| if (!hRequest)
| {
| InternetCloseHandle(hConnection);
| InternetCloseHandle(hInternet);
| return TRUE;
| }
|
| DWORD dwSecuFlags = 0;
| DWORD dwBufLen = sizeof (dwSecuFlags);
| BOOL ok = InternetQueryOption (hRequest,
INTERNET_OPTION_SECURITY_FLAGS,
| &dwSecuFlags, &dwBufLen);
| dwSecuFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA |
| SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |
| SECURITY_FLAG_IGNORE_CERT_CN_INVALID |
| SECURITY_FLAG_IGNORE_WRONG_USAGE;
|
|
| if (!InternetSetOption (hRequest, INTERNET_OPTION_SECURITY_FLAGS,
| &dwSecuFlags, sizeof(dwSecuFlags)))
| {
| InternetCloseHandle(hRequest);
| InternetCloseHandle(hConnection);
| InternetCloseHandle(hInternet);
| return TRUE;
| }
|
| CStringA strHeader;
|
| CHAR szCookie[512];
| memset(szCookie, 0, sizeof(szCookie));
| sprintf(szCookie, "Cookie: %s=%s", "CYCYCY", m_lpszCookie);
|
| CHAR szBoundary[256];
| CHAR szFileHeader[512];
| CHAR szFileFooter[512];
|
| memset(szFileHeader, 0, sizeof(szFileHeader));
| memset(szFileFooter, 0, sizeof(szFileFooter));
|
| strcpy(szBoundary, "-------------12322323");
|
| strHeader += szCookie;
| strHeader += "\r\n";
| strHeader += "Content-Type: multipart/form-data; boundary=";
| strHeader += szBoundary;
| strHeader += "\r\n";
|
| strHeader += "Accept-Language: ";
| strHeader += "en-us";
| strHeader += "\r\n";
| strHeader += "Results: Results=true"; //This is custom header we need
|
| int nProxyAuthRetry = 0;
|
| INTERNET_BUFFERSA BufferIn;
|
| GetFileHeader(szFileHeader, szBoundary); //This generates some unique
| header
| GetFileFooter(szFileFooter, szBoundary); //This generates some unique
| footer
|
| bool bRetry = false;
|
| DWORD dwBufferLength = 1024;
| DWORD dwOption = INTERNET_OPTION_PROXY;
| BYTE lpBuffer[1024];
|
| //I have to do Proxy Auth. here or else it does not work even in case of
| Windows XP https
|
| if ( !m_bProxyAuthenticated && InternetQueryOption(hInternet,
dwOption,
| lpBuffer, &dwBufferLength) )
| {
| INTERNET_PROXY_INFO *pProxyInfo = (INTERNET_PROXY_INFO
*)lpBuffer;
| if ( pProxyInfo->dwAccessType == INTERNET_OPEN_TYPE_PROXY )
| {
| GetProxyAuthParams(); //This displays dialog to get user name
| and password for proxy auth.
| SetProxyAuthetication(hRequest); //this sets the user name
and
| password
| }
| }
|
| again :
| BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );
| BufferIn.Next = NULL;
| BufferIn.lpcszHeader = strHeader;
| BufferIn.dwHeadersLength = strHeader.GetLength();
| BufferIn.dwHeadersTotal = strHeader.GetLength();
| BufferIn.lpvBuffer = NULL;
| BufferIn.dwBufferLength = 0;
| BufferIn.dwBufferTotal = ( szErrorInfo ? strlen(szFileHeader) +
| strlen(szFileFooter) : m_ulTotalDataSize + strlen(szFileHeader) +
| strlen(szFileFooter));
| BufferIn.dwOffsetLow = 0;
| BufferIn.dwOffsetHigh = 0;
|
| if(!HttpSendRequestExA( hRequest, &BufferIn, NULL, HSR_INITIATE |
| HSR_SYNC, 0))
| {
| if ( IsProxyAuthRequired(hRequest) ) //this will check if the
error
| was because we still need to set the password
| {
| GetProxyAuthParams();
| SetProxyAuthetication(hRequest);
| goto again;
| }
|
| InternetCloseHandle(hRequest);
| InternetCloseHandle(hConnection);
| InternetCloseHandle(hInternet);
| return FALSE;
| }
|
| ULONG ulBytesToWrite;
| ULONG ulTotalBytesWritten = 0;
| ULONG ulBytesWritten = 0;
|
| bSuccess = TRUE;
|
| if ( szErrorInfo == NULL )
| {
| //First send the Boundary prefix required for the file
| if (!InternetWriteFile( hRequest, szFileHeader,
| (DWORD)strlen(szFileHeader), &ulBytesWritten) )
| {
| InternetCloseHandle(hRequest);
| InternetCloseHandle(hConnection);
| InternetCloseHandle(hInternet);
| return FALSE;
| }
|
| //Now send the actual file
|
| ulBytesToWrite = m_ulTotalDataSize;
|
| ULONG ulIndex = 0;
| while (ulIndex < m_ulTotalDataSize )
| {
| if (!InternetWriteFile( hRequest, &(m_lpDataBuffer[ulIndex]),
| ulBytesToWrite, &ulBytesWritten) )
| {
| bSuccess = FALSE;
| break;
| }
| ulIndex += ulBytesWritten;
| ulBytesToWrite = ( m_ulTotalDataSize - ulIndex );
| }
|
| if( !bSuccess )
| {
| InternetCloseHandle(hRequest);
| InternetCloseHandle(hConnection);
| InternetCloseHandle(hInternet);
| return FALSE;
| }
| }
|
| //Now send the end Boundary prefix required for the file
| if ( !InternetWriteFile( hRequest, szFileFooter,
strlen(szFileFooter),
| &ulBytesWritten) )
| {
| //Log GetLastError()
| }
|
| if( !HttpEndRequestA(hRequest, NULL, 0, 0) )
| {
| //Log GetLastError()
| bSuccess = FALSE;
| }
| else
| {
| bSuccess = TRUE;
| }
|
| //Read and discard any data sent by the server
|
| InternetCloseHandle(hRequest);
| InternetCloseHandle(hConnection);
| InternetCloseHandle(hInternet);
| return bSuccess;
| }
|
| ***********************************************************
|
|
|