About This File
Purpose (from Microsoft's website)
The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS). Applications can register to receive HTTP requests for particular URLs, receive HTTP requests, and send HTTP responses. The HTTP Server API includes SSL support so that applications can exchange data over secure HTTP connections without IIS.
There have been several times in the past that I wanted to either retrieve information from one of my PCs or execute commands on one of my PCs, whether it was from across the world or sitting on my couch. Since AutoIt is one of my favorite tools for automating just about anything on my PC, I looked for ways to make to make it happen. Setting up a full blown IIS server seemed like overkill so I looked for lighter weight solutions. I though about creating my own AutoIt UDP or TCP server but that just wasn't robust enough, Then I found Microsoft's HTTP Server API and it looked very promising. After doing a little research into the APIs, I found that it was flexible & robust enough to handle just about any of the tasks that I required now and in the future. So a while back I decided to wrap the API functionality that I needed into an AutoIt UDF file to allow me to easily create the functionality I needed at the time. It has come in very handy over the years. Of course it wasn't all wrapped up with a nice little bow like it is now. That only happened when I decided to share it with anyone else who could use it or learn from it.
The example file that I included is a very granular example of the steps required to get a lightweight HTTP Server up and listening for GET requests. The UDF is a wrapper for the Microsoft APIs. That means to do anything over and above what I show in the example, one would probably have to have at least a general knowledge of APIs or the ability to figure out which APIs/functions to use, what structures and data is needed to be passed to them, and in what order. However, the UDF gives a very solid foundation on which to build upon. Of course, if anyone has questions about the UDF or how to implement any particular functionality, I would probably help to the extent that I could or point you in the right direction so that you can figure out how to implement your own solution.
The APIs included in the UDF are the ones that I needed in the past to do what I needed to do. If any additional APIs need to be added to the UDF file, please make those suggestions in the related forum topic.
Being that this is basically an AutoIt wrapper for the Microsoft API functions, there's no need to create AutoIt-specific documentation. All of the UDF functions, structures, constants, and enumerations are named after their Microsoft API counterparts. Therefore, you can refer to Microsoft's extensive documentation of their HTTP Server API. As stated earlier, if there is one or more APIs that you find yourself needing for your particular solution, please suggest it in the related Example Scripts forum topic.
Microsoft HTTP Server API - Start Page
Microsoft HTTP Server API - API v2 Reference
Microsoft HTTP Server API - Programming Model
What's New in Version v1.2.1
Added _HTTPAPI_HttpReceiveRequestEntityBody(), which was authored by @dreamscd. The function returns additional request body entities. This is required when POST and PUT requests have body data but the EntityChunkCount is not used. i.e. When sending POST requests using WinHttp.
The process_post_request function, in the example script, was modified to include the processing of additional request body entities, if they exist. Thanks @dreamscd.
Corrected an issue in _HTTPAPI_GetKnownRequestHeaderValue(). It was reading header value as wchar, when it is actually stored as char.
Corrected an issue in _HTTPAPI_HttpSendHttpResponse(). Response status text was not getting set properly.
- Corrected a function header. It listed a parameter that was not being used.