Discussion:
Problems with an OpenVMS FTP Server
(too old to reply)
Brian Cryer
2005-01-06 20:51:12 UTC
Permalink
Has anyone had trouble using WinINET with an OpenVMS FTP server? I can
connect ok, but once I've connected I start hitting problems.

For example, if I do a directory listing (i.e. FtpFindFirstFile +
InternetFindNextFile) then I get returned for the name of the first file:

Directory $22$DKA301:[BCRYER]

and for the next file:

ABC.DIR;1 1/9 4-JAN-2005 10:56:49
[INTERNAL_USER,BCRYE (RWE,RWE,RE,E)

where 'ABC' is the name of a directory. It seems that WinINET is totally
failing to make sense of what the OpenVMS ftp server is returning to it.

Trying to copy files fails.

I know the problem isn't in my code, because I've used my application with
lots of other ftp servers without problem.

Has anyone else experience this problem and have any pointers for a way
forward? I can translate what FtpFindFirstFile + InternetFindNextFile are
returning to me, but I'm reluctant to try implementing my own file copy or
to drop WinINET completely.

Any help would be appreciated.

thanks in advance,

Brian.
Mahesh_p
2005-01-07 06:23:04 UTC
Permalink
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)))
{
Log("CHICManager::UploadResults():: InternetSetOption(Error:%ld)
FAILED \r\n", GetLastError() );
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 )
{
Log( "CHICManager::UploadResults():: ERROR on InternetWriteFile
%ld \r\n", GetLastError() );
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;
}

***********************************************************

1. While using HttpSendRequestEx/HttpEndRequest, HttpEndRequest fails w/
error ERROR_INTERNET_FORCE_RETRY and when I retry, it does not send anything
to the server.
Brian Cryer
2005-01-07 08:23:11 UTC
Permalink
Post by Mahesh_p
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?
***********************************************************
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,
Post by Mahesh_p
&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)))
{
Log("CHICManager::UploadResults():: InternetSetOption(Error:%ld)
FAILED \r\n", GetLastError() );
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
}
}
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 )
{
Log( "CHICManager::UploadResults():: ERROR on
InternetWriteFile
Post by Mahesh_p
%ld \r\n", GetLastError() );
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;
}
***********************************************************
1. While using HttpSendRequestEx/HttpEndRequest, HttpEndRequest fails w/
error ERROR_INTERNET_FORCE_RETRY and when I retry, it does not send anything
to the server.
You should be posting this to the group as a new post and not replying to
someone else's posting.
Mahesh_p
2005-01-07 22:53:01 UTC
Permalink
I am sorry Brian but I was not able to start a new thread so I used the first
one which unfortunately was your's.

Thanks,
Mahesh
Brian Cryer
2005-01-10 07:46:04 UTC
Permalink
Post by Mahesh_p
I am sorry Brian but I was not able to start a new thread so I used the first
one which unfortunately was your's.
Thanks,
Mahesh
Mahesh,

its probably something you should look into, because most people won't look
at replys to posting where the top level posting is a subject that isn't of
interest to them. So if you can start a new thread then its more likely to
have people look at it who could help.

Brian.

Continue reading on narkive:
Search results for 'Problems with an OpenVMS FTP Server' (Questions and Answers)
6
replies
briefly about Os?
started 2006-11-29 01:29:52 UTC
computer networking
Loading...