I want to make HTTP requests in my server (a COM component, which would be
instantiated inside a ASP).
For this which one would be better out WinInet and WinHTTP and why?
Also i need to make HTTP requests very frequently in my server. Then would
it be a good idea to create a pool ( pre-allocated objects) of "handles"
returned by WinHttpOpen call, so that i can REUSE these handles everytime i
need to make a HTTP request. This way i would save initialization time
required by calling WinHttpOpen. Will this work fine?
Also is "ServerXMLHttp" object of MS-XML4.0 (based on WinHTTP)
"multi-threaded" or it is "apartment" threaded like
"XMLHttpRequest"?
Thanks,
Regards,
Naresh Agarwal
> I want to make HTTP requests in my server (a COM component, which would be
> instantiated inside a ASP).
>
> For this which one would be better out WinInet and WinHTTP and why?
>
WinHTTP is the _only_ choice for your scenario.
WinInet is not supported for use in server- or service-based applications,
see KB article Q238425:
http://support.microsoft.com/support/kb/articles/Q238/4/25.ASP
WinInet was designed for single-user, desktop client applications only (such
as browser-based apps); WinHTTP was designed primarily for multi-user,
server-based applications (including components that run in server
environments such as ASP).
> Also i need to make HTTP requests very frequently in my server. Then would
> it be a good idea to create a pool ( pre-allocated objects) of "handles"
> returned by WinHttpOpen call, so that i can REUSE these handles everytime
i
> need to make a HTTP request. This way i would save initialization time
> required by calling WinHttpOpen. Will this work fine?
>
Pooling WinHTTP handles is not recommended, nor even necessary. Creating
WinHTTP handles is not very expensive. What is expensive is creating the TCP
socket connections to the target server, and WinHTTP automatically manages
these connections efficiently, even if you do not pool WinHTTP handles
yourself in your code. WinHTTP implements a cross-session, global pool of
(non-authenticated) socket connections. Pooling the Session handles yourself
will not improve performance.
Furthermore, a WinHTTP Session handle (created by WinHttpOpen) should _not_
be shared among different clients. A WinHTTP Session may store sensitive,
per-user data (such as cookies or authentication contexts) and sharing
WinHTTP Sessions across clients may create a security hole in your
application. If your application or component runs in an environment where
all the clients are anonymous, then it is Ok to use a single Session;
otherwise, you should create a new Session for each client.
Since you are building a component that will run in an ASP server
environment, your component should create (and destroy) a single WinHTTP
Session per request (assuming your component only makes one request per
client). This is what the WinHttpRequest component does, for example.
> Also is "ServerXMLHttp" object of MS-XML4.0 (based on WinHTTP)
> "multi-threaded" or it is "apartment" threaded like
> "XMLHttpRequest"?
ServerXMLHTTP and WinHttpRequest are both Apartment-threaded. You cannot
pool these object across threads.
Regards,
Stephen Sulzer
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2001 Microsoft Corporation. All rights
reserved.
"Naresh Agarwal" <naga...@firstrain.com> wrote in message
news:##TnHRkVBHA.2172@tkmsftngp03...