This method will block the current thread until a connection has
been established or the timeout period has elapsed. To prevent it from
blocking the main user interface thread, the application should create
a background worker thread and establish a connection by calling the
ProxyConnect method in that thread. If the application
requires multiple simultaneous connections, it is recommended you
create a worker thread for each connection.
If the HTTP_PROXY_WINDOWS proxy type is specified, then the proxy
configuration for the local system is used. If no proxy
server has been defined, then the proxy-related parameters will be
ignored and the function will establish a connection directly to the
server. The second form of the ProxyConnect method always
uses the system configuration to determine if the connection
should be made through a proxy server, which is why there are no
parameters such as the proxy type or proxy server name.
The dwOptions argument can be used to specify the threading
model that is used by the library when a connection is established.
By default, the handle is initially attached to the thread that
created it. From that point on, until the handle is released, only the
owner may call functions using that handle. The ownership of the
handle may be transferred from one thread to another using the
HttpAttachThread function.
Specifying the HTTP_OPTION_FREETHREAD option enables any thread to
call any function using the handle, regardless of which thread
created it. It is important to note that this option disables certain
internal safety checks which are performed by the library and may
result in unexpected behavior unless access to the handle is
synchronized. If one thread calls a function in the library, it must
ensure that no other thread will call another function at the same
time using the same handle.
If the HTTP_OPTION_KEEPALIVE option is specified and the server
does not support persistent connections, the client will automatically
reconnect when each resource is requested. Although it will not
provide any performance benefits, this allows the option to be used
with all servers. This option is automatically enabled when using
HTTP/2 or HTTP/3.
Using the HTTP_OPTION_NOUSERAGENT option to prevent sending a
User-Agent header does not make requests anonymous. Servers may still
identify clients based on IP address information, authentication
credentials, request patterns or other HTTP headers included with
the request.
Applications should use HTTP_VERSION_DEFAULT as the value for
the dwVersion parameter. This will default to an appropriate
version for the Windows platform and ensures the broadest compatibility
with most servers. If your application specifies HTTP_VERSION_20,
a secure connection using TLS 1.2 or later will always be used. The
minimum required platform for HTTP/2 support is Windows 10 (Build 1903)
or Windows Server 2019. Earlier versions of the Schannel SSP do not
support the features required for a secure HTTP/2 connection.
If your application requests a HTTP/2 connection and the server
only accepts earlier versions of the protocol, the client will attempt
to automatically downgrade the request to HTTP/1.1. If a connection
using an earlier version of the protocol cannot be established, the
function will fail and return zero.
You should only attempt to use HTTP/3 if you know the server
supports that version of the protocol. If the server does not support
HTTP/3, the client will wait for the timeout period to elapse to
determine the server is not responding to the HTTP/3 request and will
then attempt to use HTTP/2. If you specify HTTP/3 as the protocol
version and you are experiencing long delays for requests the
complete, the most likely reason is the server does not support the
QUIC protocol and every request is falling back to use HTTP/2 instead.
The minimum required platform for HTTP/3 support is Windows 11 21H2
and later builds or Windows Server 2022 or later.