You are not logged in.
Pages: 1
How to add custom HTTP header to client request?
Last edited by jaclas (2017-07-14 09:45:38)
Offline
Any suggestion?
Do I have to override this method:
function TSQLHttpClientRequest.InternalRequest(const url, method: RawUTF8; var Header, Data, DataType: RawUTF8): Int64Rec;
?
Offline
I work with interface-based service.
I want add some header for debug purpose. In header because I can add in one place to debug in all services at once.
Offline
I did this:
type
TMySQLHttpClientRequest = class(TSQLHttpClientWinHTTP)
protected
function InternalRequest(const url, method: RawUTF8; var Header, Data, DataType: RawUTF8): Int64Rec; override;
end;
implementation
function TMySQLHttpClientRequest.InternalRequest(const url, method: RawUTF8; var Header, Data, DataType: RawUTF8): Int64Rec;
begin
Header := 'myheader: somedata';
Result := inherited InternalRequest(url, method, Header, Data, DataType);
end;
And it works :-)
Are there any hidden side effects here?
Offline
You mean should I do something like this:
if Header <> '' then
begin
Header := Header + #13#10 + 'myheader: somedata';
end;
?
Offline
Thanks for tip with AddToCSV!
But I have one question.
This code:
if Header <> '' then
Header := Header + #13#10;
Header := Header + 'myheader: somedata';
is better than:
if Header <> '' then
begin
Header := Header + #13#10 + 'myheader: somedata';
end;
...because? You mean better memory management? Less allocations? Or...?
Offline
Oops... My total disgrace! Sorry :-)
Offline
Pages: 1