Skip to content
Permalink
Browse files

added aUseSSL parameter to THttpServerRequest.Prepare

as proposed by Eugene Ilyin
- and enhanced TLS flag support
  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed May 9, 2019
1 parent f05badb commit a205433491451c6aebc6e326901985e32e06695a
Showing with 17 additions and 15 deletions.
  1. +1 −0 ReadMe.txt
  2. +2 −2 SQLite3/mORMotHttpServer.pas
  3. +2 −2 SynBidirSock.pas
  4. +2 −2 SynCommons.pas
  5. +8 −7 SynCrtSock.pas
  6. +1 −1 SynSelfTests.pas
  7. +1 −1 SynopseCommit.inc
@@ -31,6 +31,7 @@ Contributors
Eric Grange
Esmond
Esteban Martin (EMartin)
Eugene Ilyin
Eva Freimann (EVaF)
F-Vicente
Goran Despalatovic (gigo)
@@ -1154,8 +1154,8 @@ function TSQLHttpServer.NotifyCallback(aSender: TSQLRestServer;
// -> checked in WebSocketsCallback/IsActiveWebSocket
ctxt := THttpServerRequest.Create(nil,aConnectionID,nil);
try
ctxt.Prepare(FormatUTF8('%/%/%',[aSender.Model.Root,
aInterfaceDotMethodName,aFakeCallID]),'POST','','['+aParams+']','','');
ctxt.Prepare(FormatUTF8('%/%/%',[aSender.Model.Root,aInterfaceDotMethodName,
aFakeCallID]),'POST','','['+aParams+']','','',{ssl=}false);
status := fHttpServer.Callback(ctxt,aResult=nil);
if status=HTTP_SUCCESS then begin
if aResult<>nil then
@@ -1683,7 +1683,7 @@ function TWebSocketProtocolRest.FrameToInput(var request: TWebSocketFrame;
InContentType := JSON_CONTENT_TYPE_VAR;
if Method='' then
Method := 'POST';
Ctxt.Prepare(URL,Method,InHeaders,InContent,InContentType,fRemoteIP);
Ctxt.Prepare(URL,Method,InHeaders,InContent,InContentType,fRemoteIP,Ctxt.UseSSL);
aNoAnswer := NoAnswer='1';
end;
end;
@@ -3128,7 +3128,7 @@ function THttpClientWebSockets.Request(const url, method: SockString;
Ctxt := THttpServerRequest.Create(
nil,fProcess.fOwnerConnection,fProcess.fOwnerThread);
try
Ctxt.Prepare(url,method,header,data,dataType,'');
Ctxt.Prepare(url,method,header,data,dataType,'',fTLS);
resthead := FindIniNameValue(Pointer(header),'SEC-WEBSOCKET-REST: ');
if resthead='NonBlocking' then
block := wscNonBlockWithoutAnswer else
t := round(abs(dt)*MSecsPerDay) mod MSecsPerDay;
t2 := t div 3600000;
Hour := t2;
dec(t, t2*3600000);
dec(t,t2*3600000);
t2 := t div 60000;
Minute := t2;
dec(t, t2*60000);
dec(t,t2*60000);
t2 := t div 1000;
Second := t2;
MilliSecond := t-t2*1000;
@@ -33,6 +33,7 @@
- Cybexr
- EMartin
- Eric Grange
- Eugene Ilyin
- EvaF
- f-vicente
- Maciej Izak (hnb)
@@ -1078,7 +1079,7 @@ THttpServerRequest = class
// - will set input parameters URL/Method/InHeaders/InContent/InContentType
// - will reset output parameters
procedure Prepare(const aURL,aMethod,aInHeaders,aInContent,aInContentType,
aRemoteIP: SockString);
aRemoteIP: SockString; aUseSSL: boolean=false);
/// append some lines to the InHeaders input parameter
procedure AddInHeader(additionalHeader: SockString);
/// input parameter containing the caller URI
@@ -4790,7 +4791,7 @@ procedure TCrtSocket.OpenBind(const aServer, aPort: SockString;
{$ifdef MSWINDOWS}
fSecure.AfterConnection(fSock,pointer(aServer));
{$else}
raise ECrtSocket.Create('Unsupported');
raise ECrtSocket.Create('TLS is unsupported on this system');
{$endif MSWINDOWS}
fTLS := true;
except
@@ -5748,8 +5749,8 @@ constructor THttpServerRequest.Create(aServer: THttpServerGeneric;
fConnectionThread := aConnectionThread;
end;

procedure THttpServerRequest.Prepare(const aURL, aMethod,
aInHeaders, aInContent, aInContentType, aRemoteIP: SockString);
procedure THttpServerRequest.Prepare(const aURL, aMethod, aInHeaders,
aInContent, aInContentType, aRemoteIP: SockString; aUseSSL: boolean);
begin
fURL := aURL;
fMethod := aMethod;
@@ -5763,7 +5764,7 @@ procedure THttpServerRequest.Prepare(const aURL, aMethod,
fOutContent := '';
fOutContentType := '';
fOutCustomHeaders := '';
fUseSSL := false;
fUseSSL := aUseSSL;
end;

procedure THttpServerRequest.AddInHeader(additionalHeader: SockString);
@@ -6223,7 +6224,7 @@ procedure THttpServer.Process(ClientSock: THttpServerSocket;
try
respsent := false;
with ClientSock do
ctxt.Prepare(URL,Method,HeaderGetText(fRemoteIP),Content,ContentType,'');
ctxt.Prepare(URL,Method,HeaderGetText(fRemoteIP),Content,ContentType,'',ClientSock.fTLS);
try
Code := DoBeforeRequest(ctxt);
{$ifdef SYNCRTDEBUGLOW}
@@ -8788,7 +8789,7 @@ procedure THttpApiServer.Execute;
Verbs := VERB_TEXT;
Context := THttpServerRequest.Create(self,0,self);
try
// main loop
// main loop reusing a single Context instance for this thread
ReqID := 0;
Context.fServer := self;
repeat
@@ -18435,7 +18435,7 @@ procedure TestOne(const content,contentType: RawByteString);
C2 := THttpServerRequest.Create(nil,0,nil);
P2 := protocol.Clone('');
try
C1.Prepare('url','POST','headers',content,contentType,'');
C1.Prepare('url','POST','headers',content,contentType,'',false);
noAnswer1 := opcode=focBinary;
noAnswer2 := not noAnswer1;
TWebSocketProtocolRestHook(protocol).InputToFrame(C1,noAnswer1,frame,head);
@@ -1 +1 @@
'1.18.5213'
'1.18.5214'

0 comments on commit a205433

Please sign in to comment.
You can’t perform that action at this time.