News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

HTTP Server

Started by Biterider, December 24, 2020, 07:21:54 PM

Previous topic - Next topic

Biterider

Hi
To my surprise, MS released an "HTTP server API" a few years ago.
This simplifies the processing of http requests considerably.
The code is implemented in the kernel, is extremely stable and is also used by IIS.

The API is described here https://docs.microsoft.com/en-us/windows/win32/http/http-server-api-overview.

Looking at the code examples, I've implemented the assembler version and tested it with a browser and Postman http://masm32.com/board/index.php?topic=8916.msg97371#msg97371.

In the example, 2 verbs GET & POST are implemented. GET returns a greeting message and POST returns the same text that was sent in the body.
The code is simple and can be used for many purposes, such as online games, databases http://masm32.com/board/index.php?topic=8352.msg92037#msg92037, IoT projects and custom applications.
A very convenient and flexible way to exchange data with a server is using JSON. An assembler implementation can be found here
http://masm32.com/board/index.php?topic=9001.0.
For those who are concerned about security, the Server API also includes TLS/SSL https://de.wikipedia.org/wiki/Transport_Layer_Security

Attached is a working example and the necessary include file to build the project in 32/64 bit.
The included binary is compiled for 32 bit and ANSI strings.

Since you will likely want to test the code on your network, you will need administrative rights to register the URL to look for.
I've included the necessary resource to start with elevated privileges at the beginning of execution.
If you only want to work locally, these are not required.  :icon_idea:

I am very happy to see that we have all the building blocks in assembler and that we can realize very cool projects with ease.  :biggrin:
If you miss some file, please check the GitHub repository.

Regards, Biterider

TouEnMasm

Hello,
With Administrator right,answer ; failed to register the server (windows 10)
https://docs.microsoft.com/en-us/windows/win32/http/http-server-sample-application
Fa is a musical note to play with CL

jj2007

I won't have the time and resources to test it, but hey, my compliments, you are doing remarkable stuff here :thumbsup:

Biterider

Hi TouEnMasm
You admin account is missing some ACL for the registration.
Try using netsh.
The link you pointed to is the base I used for the assembler port. It is also mentioned in the header of the HttpServer.inc file along with other useful links.

Regards, Biterider

Vortex

Hi Biterider,

Starting the application, I receive the error message :

Registration error!
Start DebugCenter manually...


OS : Windows 10 64-bit

Biterider

Hi Vortex
I uploaded the debug version.  :rolleyes:
I recompiled the project for release and attached the new binary here.

Biterider

TouEnMasm


The new binary seem to connect to the server but the help menu failed to connect to url.

I post the c++ sample of microsoft.He is a dos prog and wait for a parameter or two.
It seems also to have the same fault.
Fa is a musical note to play with CL

Biterider

Hi
Glad you were able to connect to the server. The URL I used is http:\\<your IP>:8080

The help menu item "Help" shows the default pdf viewer on your system (if there is any defined) and displays the ObjAsm help file.
If you don't have a regular ObjAsm installation, nothing will be shown.

Biterider

TouEnMasm

Ok ,the sample don't connect to any url and don't show an html page.
Searching the windows samples,i find this one:
There is two versions of http,who don't used the same functions.
The sample added give the url to use to connect in version 2
But he don't show how view an html page.
The missing piece of code is to be searched somewhere.

HAPPY CHRISTMAS
Fa is a musical note to play with CL

Biterider

Hi
This code and the example from MS are not intended to display an HTML site.
It's all about plain HTTP/HTTPS.


Biterider



fearless

Thanks for the example. I found this useful as I am trying to implement a webhook receiver for an emby media server. HttpServer is basically what I need, so good to know that someone has looked at this.
I put together some Radasm Masm Api files for ease of use, for x86 version for the moment. Just open each txt file and copy and paste the contents into the correct corresponding files: \Radasm\Masm\MasmApiCall.api, \Radasm\Masm\MasmApiConst.api and \Radasm\Masm\MasmApiStruct.api

Biterider

Hi fearless
Thanks for the radasm api definition files.  :thumbsup:

Biterider