views:

60

answers:

2

I am working on a application where-in i have to hit a URL and get the HTTP status code returned from that URL. Currently I am using WININET functions to achieve this. The code to achieve this:

hOpen = InternetOpenA("MYAPP", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); hFile = InternetOpenUrlA(hOpen, url.c_str() , NULL, 0,INTERNET_FLAG_RELOAD, 0); HttpQueryInfoA(hFile,HTTP_QUERY_STATUS_CODE,(void*)buffer,&dwBufLen,NULL);

I did some checks to see the performance and i can see that on average a hit is taking about 300 milli-seconds. As i will be making multiple hits, the total time comes to about 8-10 sec which is slowing down the whole application.

Also the same is achieved on MAC is about 100 milli-seconds or so(i am using COCOA).

So are there any other APIs on WIN which i can use to get this faster?

Thanks in advance, Amit

+1  A: 

WinHTTP is the other major Win32 HTTP API. It is designed more for servers and clients without UI and thus may be faster.

Murray
+2  A: 

libcurl is another option. It is actually platform independent. The thing that you might not like with this library is that you will need some extra DLLs.

jpyllman
The 'easy interface' of libcurl is simple and support everything what you describe, look at http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
jpyllman