Discussion:
HTTPS POST and unknown proxy
(too old to reply)
Theo Carr-Brion
2005-04-29 13:08:02 UTC
Permalink
I am new to wininet and I am trying to do a HTTPS POST using wininet. It is
to be used where I do not know if the internet connection is via a proxy or
not. I would like it to connect automatically using settings from windows so
that we can say to the users that if the URL works in internet explorer it
will work in our application. What do I use for the third parameter of
InternetConnect as I do not know which port number to use? I have tried the
following but if fails if I include the flag INTERNET_FLAG_SECURE. If I do
not include this how does it know to do a secure connection?

NetHandle:=InternetOpen('MSIE 6.0', INTERNET_OPEN_TYPE_PRECONFIG, nil,
nil, 0);
if Assigned(NetHandle) then
begin
try
UrlHandle:=InternetConnect(NetHandle, PChar(lServer),
INTERNET_INVALID_PORT_NUMBER, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
if Assigned(UrlHandle) then
begin
try
RequestHandle:=HttpOpenRequest(UrlHandle, 'POST', PChar(lPath),
'HTTP/1.1', '', nil, INTERNET_FLAG_NO_CACHE_WRITE
or INTERNET_FLAG_SECURE or
INTERNET_FLAG_NO_UI or
INTERNET_FLAG_PRAGMA_NOCACHE, 0);


Thank you,

Theo Carr-Brion
Stephen Sulzer
2005-05-03 07:34:58 UTC
Permalink
In InternetConnect, you specify the port of the target server, regardless of
whether or not the request is going through a proxy server. For HTTP
requests, the default port is 80 (INTERNET_DEFAULT_HTTP_PORT), and for
HTTPS/SSL it is 443 (INTERNET_DEFAULT_HTTPS_PORT). If the target server
requires you connect to a different port, then you need to know that port
number. But you don't need to worry about the proxy configuration in
InternetConnect and HttpOpenRequest.

For an HTTPS request, you do need to specify the INTERNET_FLAG_SECURE flag
to HttpOpenRequest.

Hope that helps.

- Stephen
Post by Theo Carr-Brion
I am new to wininet and I am trying to do a HTTPS POST using wininet. It is
to be used where I do not know if the internet connection is via a proxy or
not. I would like it to connect automatically using settings from windows
so that we can say to the users that if the URL works in internet explorer
it will work in our application. What do I use for the third parameter of
InternetConnect as I do not know which port number to use? I have tried the
following but if fails if I include the flag INTERNET_FLAG_SECURE. If I do
not include this how does it know to do a secure connection?
NetHandle:=InternetOpen('MSIE 6.0', INTERNET_OPEN_TYPE_PRECONFIG, nil,
nil, 0);
if Assigned(NetHandle) then
begin
try
UrlHandle:=InternetConnect(NetHandle, PChar(lServer),
INTERNET_INVALID_PORT_NUMBER, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
if Assigned(UrlHandle) then
begin
try
RequestHandle:=HttpOpenRequest(UrlHandle, 'POST', PChar(lPath),
'HTTP/1.1', '', nil, INTERNET_FLAG_NO_CACHE_WRITE
or INTERNET_FLAG_SECURE or
INTERNET_FLAG_NO_UI or
INTERNET_FLAG_PRAGMA_NOCACHE, 0);
Thank you,
Theo Carr-Brion
Theo Carr-Brion
2005-05-04 08:23:30 UTC
Permalink
Thanks, that work a treat. Why can't Microsoft say this in the documentation
of InternetConnect?

Theo Carr-Brion
Post by Stephen Sulzer
In InternetConnect, you specify the port of the target server, regardless
of whether or not the request is going through a proxy server. For HTTP
requests, the default port is 80 (INTERNET_DEFAULT_HTTP_PORT), and for
HTTPS/SSL it is 443 (INTERNET_DEFAULT_HTTPS_PORT). If the target server
requires you connect to a different port, then you need to know that port
number. But you don't need to worry about the proxy configuration in
InternetConnect and HttpOpenRequest.
For an HTTPS request, you do need to specify the INTERNET_FLAG_SECURE flag
to HttpOpenRequest.
Hope that helps.
- Stephen
Post by Theo Carr-Brion
I am new to wininet and I am trying to do a HTTPS POST using wininet. It
is to be used where I do not know if the internet connection is via a
proxy or not. I would like it to connect automatically using settings from
windows so that we can say to the users that if the URL works in internet
explorer it will work in our application. What do I use for the third
parameter of InternetConnect as I do not know which port number to use? I
have tried the following but if fails if I include the flag
INTERNET_FLAG_SECURE. If I do not include this how does it know to do a
secure connection?
NetHandle:=InternetOpen('MSIE 6.0', INTERNET_OPEN_TYPE_PRECONFIG, nil,
nil, 0);
if Assigned(NetHandle) then
begin
try
UrlHandle:=InternetConnect(NetHandle, PChar(lServer),
INTERNET_INVALID_PORT_NUMBER, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
if Assigned(UrlHandle) then
begin
try
RequestHandle:=HttpOpenRequest(UrlHandle, 'POST', PChar(lPath),
'HTTP/1.1', '', nil, INTERNET_FLAG_NO_CACHE_WRITE
or INTERNET_FLAG_SECURE or
INTERNET_FLAG_NO_UI or
INTERNET_FLAG_PRAGMA_NOCACHE, 0);
Thank you,
Theo Carr-Brion
Continue reading on narkive:
Loading...