Skip to content

Commit

Permalink
HTTP/HTTPS update
Browse files Browse the repository at this point in the history
  • Loading branch information
butlerdj committed Jun 3, 2020
1 parent 596ef93 commit c13c4e0
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 190 deletions.
7 changes: 3 additions & 4 deletions Source/HTTP/flcHTTP.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
{$ENDIF}
{$ENDIF}

{.DEFINE HTTP_TLS}

{.DEFINE HTTPCLIENT_CUSTOM}
{.DEFINE HTTPSERVER_CUSTOM}
{$IFDEF TLS}
{$DEFINE HTTP_TLS}
{$ENDIF}

{$IFNDEF TCPCLIENT_TLS}
{$UNDEF HTTP_TLS}
Expand Down
21 changes: 14 additions & 7 deletions Source/HTTP/flcHTTPClient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,11 @@ implementation
flcBase64,
flcStringBuilder,
flcDateTime,
flcSocketLib
{$IFDEF HTTP_TLS},
flcTLSClient
{$ENDIF};
flcSocketLib,
{$IFDEF HTTP_TLS}
flcTLSTransportClient,
{$ENDIF}
flcTCPUtils;



Expand Down Expand Up @@ -1353,7 +1354,7 @@ procedure TF5HTTPClient.ProcessResponseHeader;
{$IFDEF StringIsUnicode}
FResponseCookies.Add(B.AsString);
{$ELSE}
FResponseCookies.Add(B.AsRawByteString);
FResponseCookies.Add(String(B.AsRawByteString));
{$ENDIF}
end;
FResponseRequireClose :=
Expand Down Expand Up @@ -1439,6 +1440,8 @@ procedure TF5HTTPClient.InitTCPClient;
{$IFDEF HTTP_TLS}
FTCPClient.TLSEnabled := FUseHTTPS;
TLSOpt := [];
/////
(*
if csoDontUseSSL3 in FHTTPSOptions then
Include(TLSOpt, ctoDisableSSL3);
if csoDontUseTLS10 in FHTTPSOptions then
Expand All @@ -1447,6 +1450,7 @@ procedure TF5HTTPClient.InitTCPClient;
Include(TLSOpt, ctoDisableTLS11);
if csoDontUseTLS12 in FHTTPSOptions then
Include(TLSOpt, ctoDisableTLS12);
*)
FTCPClient.TLSOptions := TLSOpt;
{$ENDIF}
InitTCPClientHost;
Expand Down Expand Up @@ -1713,11 +1717,14 @@ procedure TF5HTTPClient.ReadResponseContent;

procedure TF5HTTPClient.ReadResponse;
begin
if FState = hcsStarting then
exit;
Assert(FTCPClient.State in [csReady, csClosed]);
Assert(FState in [
hcsAwaitingResponse, hcsReceivedResponse, hcsReceivingContent,
hcsResponseComplete, hcsResponseCompleteAndClosing, hcsResponseCompleteAndClosed,
hcsRequestInterruptedAndClosed]);

try
if FState = hcsAwaitingResponse then
ReadResponseHeader;
Expand Down Expand Up @@ -1860,7 +1867,7 @@ procedure TF5HTTPClient.PrepareHTTPRequest;
else
FRequest.Header.CommonHeaders.Connection.Value := C;

FRequest.Header.FixedHeaders[hntHost] := FHost;
FRequest.Header.FixedHeaders[hntHost] := UTF8Encode(FHost);
FRequest.Header.FixedHeaders[hntUserAgent] := FUserAgent;
FRequest.Header.FixedHeaders[hntReferer] := FReferer;
FRequest.Header.FixedHeaders[hntAuthorization] := FAuthorization;
Expand Down Expand Up @@ -1900,7 +1907,7 @@ procedure TF5HTTPClient.SendStr(const S: RawByteString);
Assert(Assigned(FTCPClient));
Assert(FState in [hcsSendingRequest, hcsSendingContent]);
//
FTCPClient.Connection.WriteStrB(S);
FTCPClient.Connection.WriteByteString(S);
end;

procedure TF5HTTPClient.SendRequest;
Expand Down
Loading

0 comments on commit c13c4e0

Please sign in to comment.