C ++: getting an HTTP status code from a URL

I am working on an application in which I have to hit the URL and get the HTTP status code returned from that URL. I am currently using WININET functions to achieve this. Code for 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, (invalid *) buffer, & dwBufLen, NULL);

I did some checks to see the performance, and I see that the average number of strokes is about 300 milliseconds. Since I will make several calls, the total time is about 8-10 seconds, which slows down the entire application.

The same is achieved with a MAC address of about 100 milliseconds or so (I use COCOA).

So are there any other APIs for WIN that I can use to speed this up?

Thanks in advance, Amit

+3
source share
2 answers

libcurl is another option. It is virtually platform independent. What you may not like about this library is that you will need additional DLLs.

+2
source

WinHTTP is another important Win32 HTTP API. It is more designed for servers and clients without an interface and therefore can be faster.

+1
source

Source: https://habr.com/ru/post/1735369/


All Articles