TsgcWebSocketServer_HTTPAPI

The HTTP Server API enables applications to communicate over HTTP without using Microsoft Internet Information Server (IIS).

Introduction

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 WebSocket requests, and send WebSocket responses. The HTTP Server API includes SSL support so that applications can exchange data over secure HTTP connections without IIS. It is also designed to work with I/O completion ports.

 

The server supports the following protocols:

 

 

By default, this component requires that your application run as Administrator mode, for URL registration. If the URL has already been registered using an external tool like netsh, you can run without Admin rights, disable the property BindingOptions.ConfigureSSLCertificate to allow starting the application without admin rights.

Set FastMM4/FastMM5 as the first unit of your project.

 

Follow the steps below to configure this component:

 

1. Drop a TsgcWebSocketServer_HTTPAPI component in the form

 

2. Define the listening address and port:

 


    Server.Host = "127.0.0.1";
    Server.Port = 80;

 

3. Set Specifications allowed, by default, all specifications are allowed.

 

    RFC6455: is standard and recommended WebSocket specification.

 

    Hixie76: it's a draft and it's only recommended to establish Hixie76 connections if you want to provide support to old browsers like Safari 4.2

 

5. Create a procedure and set property Active = true

 

URL Reservation

The HTTP.SYS server uses URL reservation to assign which URL endpoints will be used by the HTTP.SYS server.

 

Basic URL Reservation

 

This is the most easy simple mode to configure the Server, basically you only set the Host and Port that the HTTP.SYS server will handle.

Example: if your server runs on the IP 127.0.0.1 and Port 80, just set the following properties


    Server.Host = "127.0.0.1";
    Server.Port = 80;

 

If the server runs in more than one IP and you want bind to multiple IPS, use the NewBinding Method. First clear the Host and Bindings property and then use the NewBinding method to define all Server Bindings.


    Server.Host = "";
    Server.Bindings.Clear;
    Server.Bindings.NewBinding("127.0.0.1", 80, '');
    Server.Bindings.NewBinding("80.50.55.11", 80, '');

If the server requires SSL connections, do the following to define the Host and Port which will be used to handle SSL connections.


    Server.Host := '127.0.0.1";
    Server.Port := 443;
    Server.SSL := true;
    Server.SSLOptions.Hash := "CERTIFICATE_HASH";

If the server requires SSL connections with multiple IP Addresses, first clear the Host and Bindings property and the register the new Bindings.


    Server.Host = "";
    Server.Bindings.Clear;
    Server.Bindings.NewBinding("127.0.0.1", 443, '', true, "CERTIFICATE_HASH1");
    Server.Bindings.NewBinding("80.50.55.11", 443, '', true, "CERTIFICATE_HASH2");

Reference

Guides