Skip to content

Commit 52251dc

Browse files
committed
Sample fixed + #43
1 parent da4965b commit 52251dc

File tree

5 files changed

+197
-206
lines changed

5 files changed

+197
-206
lines changed

Examples/Easy_Http/AplusB_Get/f_Main.pas

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ implementation
3636
procedure TfmMain.btAddClick(Sender: TObject);
3737
var
3838
curl : ICurl;
39-
stream : TRawByteStream;
4039
begin
4140
curl := CurlGet;
42-
stream := TRawByteStream.Create;
4341

4442
curl.SetUserAgent(FirefoxUserAgent)
4543
.SetUrl(CurlGetBuilder(edUrl.Text)
4644
.Param('a', edA.Text)
4745
.Param('b', edB.Text))
48-
.SetRecvStream(stream, [csfAutoDestroy])
46+
.SwitchRecvToString
4947
.Perform;
50-
memoResponse.Text := string(stream.Data)
48+
memoResponse.Text := string(curl.ResponseBody)
5149
+ #13#10#13#10'URL: ' +
5250
string(curl.GetInfo(CURLINFO_EFFECTIVE_URL));
5351
end;

Examples/Easy_Http/AplusB_Post/f_Main.pas

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ procedure TfmMain.btAddClick(Sender: TObject);
3838
var
3939
curl : ICurl;
4040
form : ICurlForm;
41-
stream : TRawByteStream;
4241
begin
4342
// Form
4443
form := CurlGetForm;
@@ -52,18 +51,15 @@ procedure TfmMain.btAddClick(Sender: TObject);
5251
// Simple version (just add a field)
5352
.Add('b', edB.Text);
5453

55-
// Stream
56-
stream := TRawByteStream.Create;
57-
5854
curl := CurlGet;
5955
curl.SetUrl(edUrl.Text)
6056
.SetOpt(CURLOPT_POST, true)
6157
// I tested it on my free hosting — it has a bot protection.
6258
.SetUserAgent(FirefoxUserAgent)
6359
.SetForm(form)
64-
.SetRecvStream(stream, [csfAutoDestroy])
60+
.SwitchRecvToString
6561
.Perform;
66-
memoResponse.Text := string(stream.Data);
62+
memoResponse.Text := string(curl.ResponseBody);
6763
end;
6864

6965
end.

0 commit comments

Comments
 (0)