ホーム › Networking.HttpServer › HttpSendHttpResponse
HttpSendHttpResponse
関数クライアントにHTTPレスポンスを送信する。
シグネチャ
// HTTPAPI.dll
#include <windows.h>
DWORD HttpSendHttpResponse(
HANDLE RequestQueueHandle,
ULONGLONG RequestId,
DWORD Flags,
HTTP_RESPONSE_V2* HttpResponse,
HTTP_CACHE_POLICY* CachePolicy, // optional
DWORD* BytesSent, // optional
void* Reserved1, // optional
DWORD Reserved2, // optional
OVERLAPPED* Overlapped, // optional
HTTP_LOG_DATA* LogData // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| RequestQueueHandle | HANDLE | in |
| RequestId | ULONGLONG | in |
| Flags | DWORD | in |
| HttpResponse | HTTP_RESPONSE_V2* | in |
| CachePolicy | HTTP_CACHE_POLICY* | inoptional |
| BytesSent | DWORD* | outoptional |
| Reserved1 | void* | optional |
| Reserved2 | DWORD | optional |
| Overlapped | OVERLAPPED* | inoutoptional |
| LogData | HTTP_LOG_DATA* | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// HTTPAPI.dll
#include <windows.h>
DWORD HttpSendHttpResponse(
HANDLE RequestQueueHandle,
ULONGLONG RequestId,
DWORD Flags,
HTTP_RESPONSE_V2* HttpResponse,
HTTP_CACHE_POLICY* CachePolicy, // optional
DWORD* BytesSent, // optional
void* Reserved1, // optional
DWORD Reserved2, // optional
OVERLAPPED* Overlapped, // optional
HTTP_LOG_DATA* LogData // optional
);[DllImport("HTTPAPI.dll", ExactSpelling = true)]
static extern uint HttpSendHttpResponse(
IntPtr RequestQueueHandle, // HANDLE
ulong RequestId, // ULONGLONG
uint Flags, // DWORD
IntPtr HttpResponse, // HTTP_RESPONSE_V2*
IntPtr CachePolicy, // HTTP_CACHE_POLICY* optional
IntPtr BytesSent, // DWORD* optional, out
IntPtr Reserved1, // void* optional
uint Reserved2, // DWORD optional
IntPtr Overlapped, // OVERLAPPED* optional, in/out
IntPtr LogData // HTTP_LOG_DATA* optional
);<DllImport("HTTPAPI.dll", ExactSpelling:=True)>
Public Shared Function HttpSendHttpResponse(
RequestQueueHandle As IntPtr, ' HANDLE
RequestId As ULong, ' ULONGLONG
Flags As UInteger, ' DWORD
HttpResponse As IntPtr, ' HTTP_RESPONSE_V2*
CachePolicy As IntPtr, ' HTTP_CACHE_POLICY* optional
BytesSent As IntPtr, ' DWORD* optional, out
Reserved1 As IntPtr, ' void* optional
Reserved2 As UInteger, ' DWORD optional
Overlapped As IntPtr, ' OVERLAPPED* optional, in/out
LogData As IntPtr ' HTTP_LOG_DATA* optional
) As UInteger
End Function' RequestQueueHandle : HANDLE
' RequestId : ULONGLONG
' Flags : DWORD
' HttpResponse : HTTP_RESPONSE_V2*
' CachePolicy : HTTP_CACHE_POLICY* optional
' BytesSent : DWORD* optional, out
' Reserved1 : void* optional
' Reserved2 : DWORD optional
' Overlapped : OVERLAPPED* optional, in/out
' LogData : HTTP_LOG_DATA* optional
Declare PtrSafe Function HttpSendHttpResponse Lib "httpapi" ( _
ByVal RequestQueueHandle As LongPtr, _
ByVal RequestId As LongLong, _
ByVal Flags As Long, _
ByVal HttpResponse As LongPtr, _
ByVal CachePolicy As LongPtr, _
ByVal BytesSent As LongPtr, _
ByVal Reserved1 As LongPtr, _
ByVal Reserved2 As Long, _
ByVal Overlapped As LongPtr, _
ByVal LogData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HttpSendHttpResponse = ctypes.windll.httpapi.HttpSendHttpResponse
HttpSendHttpResponse.restype = wintypes.DWORD
HttpSendHttpResponse.argtypes = [
wintypes.HANDLE, # RequestQueueHandle : HANDLE
ctypes.c_ulonglong, # RequestId : ULONGLONG
wintypes.DWORD, # Flags : DWORD
ctypes.c_void_p, # HttpResponse : HTTP_RESPONSE_V2*
ctypes.c_void_p, # CachePolicy : HTTP_CACHE_POLICY* optional
ctypes.POINTER(wintypes.DWORD), # BytesSent : DWORD* optional, out
ctypes.POINTER(None), # Reserved1 : void* optional
wintypes.DWORD, # Reserved2 : DWORD optional
ctypes.c_void_p, # Overlapped : OVERLAPPED* optional, in/out
ctypes.c_void_p, # LogData : HTTP_LOG_DATA* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('HTTPAPI.dll')
HttpSendHttpResponse = Fiddle::Function.new(
lib['HttpSendHttpResponse'],
[
Fiddle::TYPE_VOIDP, # RequestQueueHandle : HANDLE
-Fiddle::TYPE_LONG_LONG, # RequestId : ULONGLONG
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # HttpResponse : HTTP_RESPONSE_V2*
Fiddle::TYPE_VOIDP, # CachePolicy : HTTP_CACHE_POLICY* optional
Fiddle::TYPE_VOIDP, # BytesSent : DWORD* optional, out
Fiddle::TYPE_VOIDP, # Reserved1 : void* optional
-Fiddle::TYPE_INT, # Reserved2 : DWORD optional
Fiddle::TYPE_VOIDP, # Overlapped : OVERLAPPED* optional, in/out
Fiddle::TYPE_VOIDP, # LogData : HTTP_LOG_DATA* optional
],
-Fiddle::TYPE_INT)#[link(name = "httpapi")]
extern "system" {
fn HttpSendHttpResponse(
RequestQueueHandle: *mut core::ffi::c_void, // HANDLE
RequestId: u64, // ULONGLONG
Flags: u32, // DWORD
HttpResponse: *mut HTTP_RESPONSE_V2, // HTTP_RESPONSE_V2*
CachePolicy: *mut HTTP_CACHE_POLICY, // HTTP_CACHE_POLICY* optional
BytesSent: *mut u32, // DWORD* optional, out
Reserved1: *mut (), // void* optional
Reserved2: u32, // DWORD optional
Overlapped: *mut OVERLAPPED, // OVERLAPPED* optional, in/out
LogData: *mut HTTP_LOG_DATA // HTTP_LOG_DATA* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("HTTPAPI.dll")]
public static extern uint HttpSendHttpResponse(IntPtr RequestQueueHandle, ulong RequestId, uint Flags, IntPtr HttpResponse, IntPtr CachePolicy, IntPtr BytesSent, IntPtr Reserved1, uint Reserved2, IntPtr Overlapped, IntPtr LogData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'HTTPAPI_HttpSendHttpResponse' -Namespace Win32 -PassThru
# $api::HttpSendHttpResponse(RequestQueueHandle, RequestId, Flags, HttpResponse, CachePolicy, BytesSent, Reserved1, Reserved2, Overlapped, LogData)#uselib "HTTPAPI.dll"
#func global HttpSendHttpResponse "HttpSendHttpResponse" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; HttpSendHttpResponse RequestQueueHandle, RequestId, Flags, varptr(HttpResponse), varptr(CachePolicy), varptr(BytesSent), Reserved1, Reserved2, varptr(Overlapped), varptr(LogData) ; 戻り値は stat
; RequestQueueHandle : HANDLE -> "sptr"
; RequestId : ULONGLONG -> "sptr"
; Flags : DWORD -> "sptr"
; HttpResponse : HTTP_RESPONSE_V2* -> "sptr"
; CachePolicy : HTTP_CACHE_POLICY* optional -> "sptr"
; BytesSent : DWORD* optional, out -> "sptr"
; Reserved1 : void* optional -> "sptr"
; Reserved2 : DWORD optional -> "sptr"
; Overlapped : OVERLAPPED* optional, in/out -> "sptr"
; LogData : HTTP_LOG_DATA* optional -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "HTTPAPI.dll" #cfunc global HttpSendHttpResponse "HttpSendHttpResponse" sptr, int64, int, var, var, var, sptr, int, var, var ; res = HttpSendHttpResponse(RequestQueueHandle, RequestId, Flags, HttpResponse, CachePolicy, BytesSent, Reserved1, Reserved2, Overlapped, LogData) ; RequestQueueHandle : HANDLE -> "sptr" ; RequestId : ULONGLONG -> "int64" ; Flags : DWORD -> "int" ; HttpResponse : HTTP_RESPONSE_V2* -> "var" ; CachePolicy : HTTP_CACHE_POLICY* optional -> "var" ; BytesSent : DWORD* optional, out -> "var" ; Reserved1 : void* optional -> "sptr" ; Reserved2 : DWORD optional -> "int" ; Overlapped : OVERLAPPED* optional, in/out -> "var" ; LogData : HTTP_LOG_DATA* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。#uselib "HTTPAPI.dll" #cfunc global HttpSendHttpResponse "HttpSendHttpResponse" sptr, int64, int, sptr, sptr, sptr, sptr, int, sptr, sptr ; res = HttpSendHttpResponse(RequestQueueHandle, RequestId, Flags, varptr(HttpResponse), varptr(CachePolicy), varptr(BytesSent), Reserved1, Reserved2, varptr(Overlapped), varptr(LogData)) ; RequestQueueHandle : HANDLE -> "sptr" ; RequestId : ULONGLONG -> "int64" ; Flags : DWORD -> "int" ; HttpResponse : HTTP_RESPONSE_V2* -> "sptr" ; CachePolicy : HTTP_CACHE_POLICY* optional -> "sptr" ; BytesSent : DWORD* optional, out -> "sptr" ; Reserved1 : void* optional -> "sptr" ; Reserved2 : DWORD optional -> "int" ; Overlapped : OVERLAPPED* optional, in/out -> "sptr" ; LogData : HTTP_LOG_DATA* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。 ; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; DWORD HttpSendHttpResponse(HANDLE RequestQueueHandle, ULONGLONG RequestId, DWORD Flags, HTTP_RESPONSE_V2* HttpResponse, HTTP_CACHE_POLICY* CachePolicy, DWORD* BytesSent, void* Reserved1, DWORD Reserved2, OVERLAPPED* Overlapped, HTTP_LOG_DATA* LogData) #uselib "HTTPAPI.dll" #cfunc global HttpSendHttpResponse "HttpSendHttpResponse" intptr, int64, int, var, var, var, intptr, int, var, var ; res = HttpSendHttpResponse(RequestQueueHandle, RequestId, Flags, HttpResponse, CachePolicy, BytesSent, Reserved1, Reserved2, Overlapped, LogData) ; RequestQueueHandle : HANDLE -> "intptr" ; RequestId : ULONGLONG -> "int64" ; Flags : DWORD -> "int" ; HttpResponse : HTTP_RESPONSE_V2* -> "var" ; CachePolicy : HTTP_CACHE_POLICY* optional -> "var" ; BytesSent : DWORD* optional, out -> "var" ; Reserved1 : void* optional -> "intptr" ; Reserved2 : DWORD optional -> "int" ; Overlapped : OVERLAPPED* optional, in/out -> "var" ; LogData : HTTP_LOG_DATA* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD HttpSendHttpResponse(HANDLE RequestQueueHandle, ULONGLONG RequestId, DWORD Flags, HTTP_RESPONSE_V2* HttpResponse, HTTP_CACHE_POLICY* CachePolicy, DWORD* BytesSent, void* Reserved1, DWORD Reserved2, OVERLAPPED* Overlapped, HTTP_LOG_DATA* LogData) #uselib "HTTPAPI.dll" #cfunc global HttpSendHttpResponse "HttpSendHttpResponse" intptr, int64, int, intptr, intptr, intptr, intptr, int, intptr, intptr ; res = HttpSendHttpResponse(RequestQueueHandle, RequestId, Flags, varptr(HttpResponse), varptr(CachePolicy), varptr(BytesSent), Reserved1, Reserved2, varptr(Overlapped), varptr(LogData)) ; RequestQueueHandle : HANDLE -> "intptr" ; RequestId : ULONGLONG -> "int64" ; Flags : DWORD -> "int" ; HttpResponse : HTTP_RESPONSE_V2* -> "intptr" ; CachePolicy : HTTP_CACHE_POLICY* optional -> "intptr" ; BytesSent : DWORD* optional, out -> "intptr" ; Reserved1 : void* optional -> "intptr" ; Reserved2 : DWORD optional -> "int" ; Overlapped : OVERLAPPED* optional, in/out -> "intptr" ; LogData : HTTP_LOG_DATA* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
httpapi = windows.NewLazySystemDLL("HTTPAPI.dll")
procHttpSendHttpResponse = httpapi.NewProc("HttpSendHttpResponse")
)
// RequestQueueHandle (HANDLE), RequestId (ULONGLONG), Flags (DWORD), HttpResponse (HTTP_RESPONSE_V2*), CachePolicy (HTTP_CACHE_POLICY* optional), BytesSent (DWORD* optional, out), Reserved1 (void* optional), Reserved2 (DWORD optional), Overlapped (OVERLAPPED* optional, in/out), LogData (HTTP_LOG_DATA* optional)
r1, _, err := procHttpSendHttpResponse.Call(
uintptr(RequestQueueHandle),
uintptr(RequestId),
uintptr(Flags),
uintptr(HttpResponse),
uintptr(CachePolicy),
uintptr(BytesSent),
uintptr(Reserved1),
uintptr(Reserved2),
uintptr(Overlapped),
uintptr(LogData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction HttpSendHttpResponse(
RequestQueueHandle: THandle; // HANDLE
RequestId: UInt64; // ULONGLONG
Flags: DWORD; // DWORD
HttpResponse: Pointer; // HTTP_RESPONSE_V2*
CachePolicy: Pointer; // HTTP_CACHE_POLICY* optional
BytesSent: Pointer; // DWORD* optional, out
Reserved1: Pointer; // void* optional
Reserved2: DWORD; // DWORD optional
Overlapped: Pointer; // OVERLAPPED* optional, in/out
LogData: Pointer // HTTP_LOG_DATA* optional
): DWORD; stdcall;
external 'HTTPAPI.dll' name 'HttpSendHttpResponse';result := DllCall("HTTPAPI\HttpSendHttpResponse"
, "Ptr", RequestQueueHandle ; HANDLE
, "Int64", RequestId ; ULONGLONG
, "UInt", Flags ; DWORD
, "Ptr", HttpResponse ; HTTP_RESPONSE_V2*
, "Ptr", CachePolicy ; HTTP_CACHE_POLICY* optional
, "Ptr", BytesSent ; DWORD* optional, out
, "Ptr", Reserved1 ; void* optional
, "UInt", Reserved2 ; DWORD optional
, "Ptr", Overlapped ; OVERLAPPED* optional, in/out
, "Ptr", LogData ; HTTP_LOG_DATA* optional
, "UInt") ; return: DWORD●HttpSendHttpResponse(RequestQueueHandle, RequestId, Flags, HttpResponse, CachePolicy, BytesSent, Reserved1, Reserved2, Overlapped, LogData) = DLL("HTTPAPI.dll", "dword HttpSendHttpResponse(void*, qword, dword, void*, void*, void*, void*, dword, void*, void*)")
# 呼び出し: HttpSendHttpResponse(RequestQueueHandle, RequestId, Flags, HttpResponse, CachePolicy, BytesSent, Reserved1, Reserved2, Overlapped, LogData)
# RequestQueueHandle : HANDLE -> "void*"
# RequestId : ULONGLONG -> "qword"
# Flags : DWORD -> "dword"
# HttpResponse : HTTP_RESPONSE_V2* -> "void*"
# CachePolicy : HTTP_CACHE_POLICY* optional -> "void*"
# BytesSent : DWORD* optional, out -> "void*"
# Reserved1 : void* optional -> "void*"
# Reserved2 : DWORD optional -> "dword"
# Overlapped : OVERLAPPED* optional, in/out -> "void*"
# LogData : HTTP_LOG_DATA* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。