You are not logged in.
Hi Folks,
i want to send binary data (a Picture) with additional HTTP-Header-Data from an Android-App using Firemonkey (FMX) to a method-based service.
But in unit SynCrossPlatformSpecific.pas procedure THttpClientHttpConnectionClass.URI(var Call: TSQLRestURIParams, ...) the HTTP-Headers in parameter Call.InHead are not used/sent.
IMHO the Call.InHead must be filled into a TNetHeader array and passed to the THttpClient.Post/.Put/.. functions.
Here is a working - but naive and memory-leaking function:
procedure TextToNetHeaders(Text : String; var Headers : TNetHeaders);
var
Pairs : Integer;
sl : TStringList;
i, Sep : Integer;
begin
sl := TStringList.Create;
try
sl.Text := Text;
SetLength(Headers, sl.Count);
for i := 0 to sl.Count - 1 do begin
Sep := Pos(':', sl[i]);
Headers[i] := TNetHeader.Create(Trim(Copy(sl[i], 1, Sep - 1)),
trim(Copy(sl[i], Sep + 1, MAXINT)));
end;
finally
sl.Free;
end;
end;
Can you please help cleaning up the function/solution and push upstream?
Edit: removed [BUG] from title
Last edited by sevo (2018-08-30 08:18:52)
Offline
Offline
Thx for your reply!
Instead of HTTP-Headers I should use URL-Parameters.
I managed to do so using UrlEncode:
Call.InBody := //binary data from picture
Call.Url := Client.Model.Root + '/' + 'UploadPicture' + UrlEncode(['Param', 123, 'Context', 456]);
Call.Verb := 'POST';
Client.URI(Call);
Why are in UrlEncode only a-zA-Z as parameter names allowed?
According to https://www.ietf.org/rfc/rfc3986.txt the query can consist of *( pchar / "/" / "?" )
Where pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
and unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
Edit: typo
Last edited by sevo (2018-08-29 11:39:36)
Offline