View Issue Details

IDProjectCategoryView StatusLast Update
0037253FPCPackagespublic2020-06-26 23:13
ReporterTaufik Rahmad Hidayanto Assigned ToSven Barth  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOSWindows 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0037253: HttpApi not work
DescriptionHttpApi.pp

VER3_0 no longer available in FPC 3.2.0

{$IFDEF VER3_0}
  type
    PWSTR = PWideChar;

{$MACRO ON}
{$DEFINE winapi:=stdcall}

{$ENDIF}
Steps To Reproduceuses
  Windows, Winsock2, HttpApi;

var
  ret: ULONG;
begin
  ret := HttpApi.HttpInitialize(HTTPAPI_VERSION_2, HTTP_INITIALIZE_SERVER, nil);
  if ret <> NO_ERROR then
    WriteLn('HttpInitialize Error ', ret); // error 87 (ERROR_INVALID_PARAMETER)

  WriteLn('HttpApi.SOCKADDR_STORAGE: ', SizeOf(HttpApi.SOCKADDR_STORAGE)); // output 136
  // SOCKADDR_STORAGE already defined in Winsock2 (the correct size)
  WriteLn('Winsock2.SOCKADDR_STORAGE: ', SizeOf(Winsock2.SOCKADDR_STORAGE)); // output 128
Additional InformationAttachment contain the latest Http Api (Windows SDK 10.0.19041.0) and test size of record (win32 and win64)
TagsNo tags attached.
Fixed in Revision45692,45693,45694
FPCOldBugId
FPCTarget-
Attached Files

Activities

Taufik Rahmad Hidayanto

2020-06-25 07:17

reporter  

httpSys.zip (21,347 bytes)

Sven Barth

2020-06-25 22:49

manager   ~0123595

The check for VER3_0 was simply to allow the unit to be used with FPC 3.0, cause I had originally developed it there, I've now removed that code as well as the SOCKADDR_STORAGE declaration.

The WinAPI modifier sadly had a bug and thus the HttpApi unit won't work on Win32. As Win64 won't be affected you'll have to use Win64 if you also want to use fpWeb. Or you have to change all occurrences of WinAPI to StdCall and recompile the HttpApi as well as the custHttpSys and fpHttpSys units.

The fixes for these points will be merged to 3.2.x and will be available in a future 3.2.2.

Please note that I won't simply overwrite our HttpApi unit with the conversion you have done. If you're missing specfic functionality, then please provide a patch against our unit.

Taufik Rahmad Hidayanto

2020-06-26 17:52

reporter   ~0123602

Missing function HttpUpdateServiceConfiguration
This function is useful for update existing configuration

// Set new SSL
e := HttpSetServiceConfiguration(...);
if e = ERROR_ALREADY_EXISTS then
begin
// https://docs.microsoft.com/en-us/windows/win32/api/http/nf-http-httpsetserviceconfiguration
// The specified record already exists, and must be deleted in order for its value to be re-set.
// Update existing configuration rather than delete the existing configuration
//
// Do update existing SSL configuration
HttpUpdateServiceConfiguration(...);
end;

function HttpUpdateServiceConfiguration(
    ServiceHandle: THandle;
    ConfigId: HTTP_SERVICE_CONFIG_ID;
    ConfigInfo: PVOID;
    ConfigInfoLength: ULONG;
    Overlapped: LPOVERLAPPED
  ): ULONG; WinApi; external External_library name 'HttpUpdateServiceConfiguration';


Suggestion:
Add operator (advanced record) on HTTP_VERSION and HTTPAPI_VERSION record

HTTP_VERSION = record
  MajorVersion: USHORT;
  MinorVersion: USHORT;
public
  class operator = (const A, B: HTTP_VERSION): Boolean; inline;
  class operator <> (const A, B: HTTP_VERSION): Boolean; inline;
  class operator > (const A, B: HTTP_VERSION): Boolean; inline;
  class operator >= (const A, B: HTTP_VERSION): Boolean; inline;
  class operator < (const A, B: HTTP_VERSION): Boolean; inline;
  class operator <= (const A, B: HTTP_VERSION): Boolean; inline;
public
  constructor Create(major, minor: USHORT);
end;

its look new HttpSys ready for HTTP 3.0
new macro added in the latest win SDK
HTTP_VERSION_3_0 : HTTP_VERSION = (MajorVersion: 3; MinorVersion: 0);

Sven Barth

2020-06-26 23:13

manager   ~0123605

Please report as a new bug. This one was about not working HttpApi.

Issue History

Date Modified Username Field Change
2020-06-25 07:17 Taufik Rahmad Hidayanto New Issue
2020-06-25 07:17 Taufik Rahmad Hidayanto File Added: httpSys.zip
2020-06-25 22:49 Sven Barth Assigned To => Sven Barth
2020-06-25 22:49 Sven Barth Status new => resolved
2020-06-25 22:49 Sven Barth Resolution open => fixed
2020-06-25 22:49 Sven Barth Fixed in Version => 3.3.1
2020-06-25 22:49 Sven Barth Fixed in Revision => 45692,45693,45694
2020-06-25 22:49 Sven Barth FPCTarget => -
2020-06-25 22:49 Sven Barth Note Added: 0123595
2020-06-26 17:52 Taufik Rahmad Hidayanto Note Added: 0123602
2020-06-26 23:13 Sven Barth Note Added: 0123605