Win32 API 日本語リファレンス
ホームNetworking.HttpServer › HttpDeclarePush

HttpDeclarePush

関数
HTTP/2のサーバープッシュ要求を宣言する。
DLLHTTPAPI.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

// HTTPAPI.dll
#include <windows.h>

DWORD HttpDeclarePush(
    HANDLE RequestQueueHandle,
    ULONGLONG RequestId,
    HTTP_VERB Verb,
    LPCWSTR Path,
    LPCSTR Query,   // optional
    HTTP_REQUEST_HEADERS* Headers   // optional
);

パラメーター

名前方向
RequestQueueHandleHANDLEin
RequestIdULONGLONGin
VerbHTTP_VERBin
PathLPCWSTRin
QueryLPCSTRinoptional
HeadersHTTP_REQUEST_HEADERS*inoptional

戻り値の型: DWORD

各言語での呼び出し定義

// HTTPAPI.dll
#include <windows.h>

DWORD HttpDeclarePush(
    HANDLE RequestQueueHandle,
    ULONGLONG RequestId,
    HTTP_VERB Verb,
    LPCWSTR Path,
    LPCSTR Query,   // optional
    HTTP_REQUEST_HEADERS* Headers   // optional
);
[DllImport("HTTPAPI.dll", ExactSpelling = true)]
static extern uint HttpDeclarePush(
    IntPtr RequestQueueHandle,   // HANDLE
    ulong RequestId,   // ULONGLONG
    int Verb,   // HTTP_VERB
    [MarshalAs(UnmanagedType.LPWStr)] string Path,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPStr)] string Query,   // LPCSTR optional
    IntPtr Headers   // HTTP_REQUEST_HEADERS* optional
);
<DllImport("HTTPAPI.dll", ExactSpelling:=True)>
Public Shared Function HttpDeclarePush(
    RequestQueueHandle As IntPtr,   ' HANDLE
    RequestId As ULong,   ' ULONGLONG
    Verb As Integer,   ' HTTP_VERB
    <MarshalAs(UnmanagedType.LPWStr)> Path As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPStr)> Query As String,   ' LPCSTR optional
    Headers As IntPtr   ' HTTP_REQUEST_HEADERS* optional
) As UInteger
End Function
' RequestQueueHandle : HANDLE
' RequestId : ULONGLONG
' Verb : HTTP_VERB
' Path : LPCWSTR
' Query : LPCSTR optional
' Headers : HTTP_REQUEST_HEADERS* optional
Declare PtrSafe Function HttpDeclarePush Lib "httpapi" ( _
    ByVal RequestQueueHandle As LongPtr, _
    ByVal RequestId As LongLong, _
    ByVal Verb As Long, _
    ByVal Path As LongPtr, _
    ByVal Query As String, _
    ByVal Headers As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HttpDeclarePush = ctypes.windll.httpapi.HttpDeclarePush
HttpDeclarePush.restype = wintypes.DWORD
HttpDeclarePush.argtypes = [
    wintypes.HANDLE,  # RequestQueueHandle : HANDLE
    ctypes.c_ulonglong,  # RequestId : ULONGLONG
    ctypes.c_int,  # Verb : HTTP_VERB
    wintypes.LPCWSTR,  # Path : LPCWSTR
    wintypes.LPCSTR,  # Query : LPCSTR optional
    ctypes.c_void_p,  # Headers : HTTP_REQUEST_HEADERS* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('HTTPAPI.dll')
HttpDeclarePush = Fiddle::Function.new(
  lib['HttpDeclarePush'],
  [
    Fiddle::TYPE_VOIDP,  # RequestQueueHandle : HANDLE
    -Fiddle::TYPE_LONG_LONG,  # RequestId : ULONGLONG
    Fiddle::TYPE_INT,  # Verb : HTTP_VERB
    Fiddle::TYPE_VOIDP,  # Path : LPCWSTR
    Fiddle::TYPE_VOIDP,  # Query : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # Headers : HTTP_REQUEST_HEADERS* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "httpapi")]
extern "system" {
    fn HttpDeclarePush(
        RequestQueueHandle: *mut core::ffi::c_void,  // HANDLE
        RequestId: u64,  // ULONGLONG
        Verb: i32,  // HTTP_VERB
        Path: *const u16,  // LPCWSTR
        Query: *const u8,  // LPCSTR optional
        Headers: *mut HTTP_REQUEST_HEADERS  // HTTP_REQUEST_HEADERS* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("HTTPAPI.dll")]
public static extern uint HttpDeclarePush(IntPtr RequestQueueHandle, ulong RequestId, int Verb, [MarshalAs(UnmanagedType.LPWStr)] string Path, [MarshalAs(UnmanagedType.LPStr)] string Query, IntPtr Headers);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HTTPAPI_HttpDeclarePush' -Namespace Win32 -PassThru
# $api::HttpDeclarePush(RequestQueueHandle, RequestId, Verb, Path, Query, Headers)
#uselib "HTTPAPI.dll"
#func global HttpDeclarePush "HttpDeclarePush" sptr, sptr, sptr, sptr, sptr, sptr
; HttpDeclarePush RequestQueueHandle, RequestId, Verb, Path, Query, varptr(Headers)   ; 戻り値は stat
; RequestQueueHandle : HANDLE -> "sptr"
; RequestId : ULONGLONG -> "sptr"
; Verb : HTTP_VERB -> "sptr"
; Path : LPCWSTR -> "sptr"
; Query : LPCSTR optional -> "sptr"
; Headers : HTTP_REQUEST_HEADERS* optional -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "HTTPAPI.dll"
#cfunc global HttpDeclarePush "HttpDeclarePush" sptr, int64, int, wstr, str, var
; res = HttpDeclarePush(RequestQueueHandle, RequestId, Verb, Path, Query, Headers)
; RequestQueueHandle : HANDLE -> "sptr"
; RequestId : ULONGLONG -> "int64"
; Verb : HTTP_VERB -> "int"
; Path : LPCWSTR -> "wstr"
; Query : LPCSTR optional -> "str"
; Headers : HTTP_REQUEST_HEADERS* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD HttpDeclarePush(HANDLE RequestQueueHandle, ULONGLONG RequestId, HTTP_VERB Verb, LPCWSTR Path, LPCSTR Query, HTTP_REQUEST_HEADERS* Headers)
#uselib "HTTPAPI.dll"
#cfunc global HttpDeclarePush "HttpDeclarePush" intptr, int64, int, wstr, str, var
; res = HttpDeclarePush(RequestQueueHandle, RequestId, Verb, Path, Query, Headers)
; RequestQueueHandle : HANDLE -> "intptr"
; RequestId : ULONGLONG -> "int64"
; Verb : HTTP_VERB -> "int"
; Path : LPCWSTR -> "wstr"
; Query : LPCSTR optional -> "str"
; Headers : HTTP_REQUEST_HEADERS* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	httpapi = windows.NewLazySystemDLL("HTTPAPI.dll")
	procHttpDeclarePush = httpapi.NewProc("HttpDeclarePush")
)

// RequestQueueHandle (HANDLE), RequestId (ULONGLONG), Verb (HTTP_VERB), Path (LPCWSTR), Query (LPCSTR optional), Headers (HTTP_REQUEST_HEADERS* optional)
r1, _, err := procHttpDeclarePush.Call(
	uintptr(RequestQueueHandle),
	uintptr(RequestId),
	uintptr(Verb),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Path))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Query))),
	uintptr(Headers),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function HttpDeclarePush(
  RequestQueueHandle: THandle;   // HANDLE
  RequestId: UInt64;   // ULONGLONG
  Verb: Integer;   // HTTP_VERB
  Path: PWideChar;   // LPCWSTR
  Query: PAnsiChar;   // LPCSTR optional
  Headers: Pointer   // HTTP_REQUEST_HEADERS* optional
): DWORD; stdcall;
  external 'HTTPAPI.dll' name 'HttpDeclarePush';
result := DllCall("HTTPAPI\HttpDeclarePush"
    , "Ptr", RequestQueueHandle   ; HANDLE
    , "Int64", RequestId   ; ULONGLONG
    , "Int", Verb   ; HTTP_VERB
    , "WStr", Path   ; LPCWSTR
    , "AStr", Query   ; LPCSTR optional
    , "Ptr", Headers   ; HTTP_REQUEST_HEADERS* optional
    , "UInt")   ; return: DWORD
●HttpDeclarePush(RequestQueueHandle, RequestId, Verb, Path, Query, Headers) = DLL("HTTPAPI.dll", "dword HttpDeclarePush(void*, qword, int, char*, char*, void*)")
# 呼び出し: HttpDeclarePush(RequestQueueHandle, RequestId, Verb, Path, Query, Headers)
# RequestQueueHandle : HANDLE -> "void*"
# RequestId : ULONGLONG -> "qword"
# Verb : HTTP_VERB -> "int"
# Path : LPCWSTR -> "char*"
# Query : LPCSTR optional -> "char*"
# Headers : HTTP_REQUEST_HEADERS* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。