Author Topic: HTTP Server  (Read 1614 times)

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 730
  • ObjAsm Developer
    • ObjAsm
HTTP Server
« on: December 24, 2020, 07:21:54 PM »
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

  • Member
  • *****
  • Posts: 1805
    • EditMasm
Re: HTTP Server
« Reply #1 on: December 24, 2020, 08:37:11 PM »
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

  • Member
  • *****
  • Posts: 11552
  • Assembler is fun ;-)
    • MasmBasic
Re: HTTP Server
« Reply #2 on: December 24, 2020, 09:36:40 PM »
I won't have the time and resources to test it, but hey, my compliments, you are doing remarkable stuff here :thumbsup:

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 730
  • ObjAsm Developer
    • ObjAsm
Re: HTTP Server
« Reply #3 on: December 24, 2020, 10:13:45 PM »
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

  • Member
  • *****
  • Posts: 2583
Re: HTTP Server
« Reply #4 on: December 24, 2020, 11:57:02 PM »
Hi Biterider,

Starting the application, I receive the error message :

Code: [Select]
Registration error!
Start DebugCenter manually...

OS : Windows 10 64-bit

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 730
  • ObjAsm Developer
    • ObjAsm
Re: HTTP Server
« Reply #5 on: December 25, 2020, 12:09:36 AM »
Hi Vortex
I uploaded the debug version.  :rolleyes:
I recompiled the project for release and attached the new binary here.

Biterider

TouEnMasm

  • Member
  • *****
  • Posts: 1805
    • EditMasm
Re: HTTP Server
« Reply #6 on: December 25, 2020, 01:37:39 AM »

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

  • Moderator
  • Member
  • *****
  • Posts: 730
  • ObjAsm Developer
    • ObjAsm
Re: HTTP Server
« Reply #7 on: December 25, 2020, 03:18:08 AM »
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

  • Member
  • *****
  • Posts: 1805
    • EditMasm
Re: HTTP Server
« Reply #8 on: December 25, 2020, 03:25:04 AM »
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

  • Moderator
  • Member
  • *****
  • Posts: 730
  • ObjAsm Developer
    • ObjAsm
Re: HTTP Server
« Reply #9 on: December 25, 2020, 03:40:27 AM »
Hi
This code and the example from MS are not intended to display an HTML site.
It's all about plain HTTP/HTTPS.


Biterider