Skip to content

Commit cf3aeaa

Browse files
committed
Updated A+B
1 parent 160bb62 commit cf3aeaa

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Examples/Raw_Http/AplusB_Post/f_Main.dfm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object fmMain: TfmMain
55
BorderIcons = [biSystemMenu, biMinimize]
66
BorderStyle = bsSingle
77
Caption = 'POST form demo'
8-
ClientHeight = 169
8+
ClientHeight = 165
99
ClientWidth = 306
1010
Color = clBtnFace
1111
Font.Charset = DEFAULT_CHARSET
@@ -79,7 +79,7 @@ object fmMain: TfmMain
7979
Left = 12
8080
Top = 66
8181
Width = 282
82-
Height = 95
82+
Height = 91
8383
TabOrder = 3
8484
end
8585
end

Examples/Raw_Http/AplusB_Post/f_Main.pas

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ procedure TfmMain.btAddClick(Sender: TObject);
5151
headers, headersEnd : PCurlSList;
5252
code : TCurlCode;
5353
stream : TRawByteStream;
54+
effurl : PAnsiChar;
55+
respcode : LongInt;
5456
begin
5557
post := nil;
5658
last := nil;
@@ -72,7 +74,7 @@ procedure TfmMain.btAddClick(Sender: TObject);
7274
curl_formadd_initial(post, last,
7375
CURLFORM_COPYNAME, sA,
7476
CURLFORM_COPYCONTENTS, PAnsiChar(UTF8Encode(edA.Text)),
75-
CURLFORM_CONTENTHEADER, PAnsiChar(headers),
77+
CURLFORM_CONTENTHEADER, headers,
7678
CURLFORM_END);
7779

7880
// formadd is more type-safe
@@ -85,9 +87,14 @@ procedure TfmMain.btAddClick(Sender: TObject);
8587
curl_easy_setopt(curl, CURLOPT_WRITEDATA, stream);
8688
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, @StreamWrite);
8789
code := curl_easy_perform(curl);
88-
if code = CURLE_OK
89-
then memoResponse.Text := string(stream.Data)
90-
else memoResponse.Text := string(curl_easy_strerror(code));
90+
if code = CURLE_OK then begin
91+
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, effurl);
92+
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, respcode);
93+
memoResponse.Text := string(stream.Data) + #13#10#13#10'URL: ' + effurl
94+
+ #10#10'Response code: ' + IntToStr(respcode);
95+
end else begin
96+
memoResponse.Text := string(curl_easy_strerror(code));
97+
end;
9198

9299
finally
93100
stream.Free;

0 commit comments

Comments
 (0)