The built-in routine HttpQueryInfo returns a string, not actual bytes. Normally that is not a problem.
However, lately I have begin to encounter a problem with servers issuing redirects where the location header field contains an URL which includes non-percentage-encoded unicode/or? characters. Any way around this?
var
vContent_Wide: WideString;
begin
vBufferSize := 4096;
GetMem(vBufferPtr, vBufferSize);
while True do
begin
TmpFakeCardinal := 0;
vErrorNone := HttpQueryInfo(
hHttpOpen_Request,
HTTP_QUERY_RAW_HEADERS_CRLF,
vBufferPtr,
vBufferSize,
TmpFakeCardinal
);
if (vErrorNone = False) then
begin
vErrorID := GetLastError;
if (vErrorID = ERROR_INSUFFICIENT_BUFFER) then
begin
FreeMem(vBufferPtr);
GetMem(vBufferPtr, vBufferSize);
end
else Break;
end
else
begin
vContent_Wide := PWideChar(vBufferPtr);
Result := vContent_Wide;
Break;
end
;
end;
FreeMem(vBufferPtr, vBufferSize);