Discussion:
Error in parsing command
(too old to reply)
Hannes Gouws
2008-07-17 10:03:16 UTC
Permalink
Hi Remy

I am getting an "error in parsing command" when I am trying to connect to a
TidHttpServer with SSL i.e. hhtps://192.168.0.1/login.htm.

I have traced it to: "LInputLine := IOHandler.ReadLn;" in function
TIdCustomHTTPServer.DoExecute(AContext:TIdContext): boolean; in unit
IdCustomHTTPServer;

I am using D7 with the indy snapshot from 14/07/2008.

This only happens when I try and connect form a remote pc but when I connect
locally it works fine.


Any help here would be much appreceatied!


Thanks
Hannes Gouws
2008-07-17 10:21:20 UTC
Permalink
This is what I get from the log:

192.168.0.3:1133 Stat Connected.

192.168.0.3:1133 Recv 17/07/2008 12:20:46 PM: ?L 3   
 ? À ?  @ d b   ? ?   cR
BËENüa1joë ÷

192.168.0.3:1133 Stat Disconnected.

0.0.0.0:0 Stat Disconnected.

192.168.0.3:1134 Stat Connected.

192.168.0.3:1134 Recv 17/07/2008 12:20:48 PM: ?+    ? À ? @ ?
?M¡iŠs?\3fL{z?ß
Post by Hannes Gouws
Hi Remy
I am getting an "error in parsing command" when I am trying to connect to
a TidHttpServer with SSL i.e. hhtps://192.168.0.1/login.htm.
I have traced it to: "LInputLine := IOHandler.ReadLn;" in function
TIdCustomHTTPServer.DoExecute(AContext:TIdContext): boolean; in unit
IdCustomHTTPServer;
I am using D7 with the indy snapshot from 14/07/2008.
This only happens when I try and connect form a remote pc but when I
connect locally it works fine.
Any help here would be much appreceatied!
Thanks
Remy Lebeau (TeamB)
2008-07-17 19:01:07 UTC
Permalink
Post by Hannes Gouws
192.168.0.3:1133 Recv 17/07/2008 12:20:46 PM: ?L 3   
BËENüa1joë ÷
Looks like you did not enable SSL in your TIdHTPServer, so it is trying to
parse raw encryption data.


Gambit
Remy Lebeau (TeamB)
2008-07-17 18:59:45 UTC
Permalink
Post by Hannes Gouws
I am getting an "error in parsing command" when I am trying to
connect to a TidHttpServer with SSL i.e. hhtps://192.168.0.1/login.htm.
I have traced it to: "LInputLine := IOHandler.ReadLn;" in function
TIdCustomHTTPServer.DoExecute(AContext:TIdContext): boolean;
in unit IdCustomHTTPServer;
ReadLn() cannot raise such an error.

The error is actually coming from several lines further down:

i := RPos(' ', LInputLine, -1); {Do not Localize}
if i = 0 then begin
raise EIdHTTPErrorParsingCommand.Create(RSHTTPErrorParsingCommand);
end;

Which means your client is sending a malformed HTTP request. The first line
in EVERY request must end with an HTTP version number, ie:

'GET /login.html HTTP/1.0'

Hense the call to RPos(). The error means there is no space character
anywhere in the line.


Gambit
Hannes Gouws
2008-07-18 05:34:41 UTC
Permalink
Hi Remy

Thanks for your reply.

True, it does come from "raise
EIdHTTPErrorParsingCommand.Create(RSHTTPErrorParsingCommand);" however what
I meant was that the problem originated with ReadLn() which returns
"garbage" and then the error will subsequently be raised further down.

Looking at it again this morning with fresh eyes and a fresh mind I noticed
almost immediately that my packet redirection code was sending https
requests to port 80, hence the raw encryption data. This is why it worked
when connecting from my local to my local, but not when I tried connecting
remotely. I changed my packet redirection code recently.... Oi, sometimes I
can just kick myself!


Thanks for your effort!

Regards
Hannes
Post by Remy Lebeau (TeamB)
Post by Hannes Gouws
I am getting an "error in parsing command" when I am trying to
connect to a TidHttpServer with SSL i.e. hhtps://192.168.0.1/login.htm.
I have traced it to: "LInputLine := IOHandler.ReadLn;" in function
TIdCustomHTTPServer.DoExecute(AContext:TIdContext): boolean;
in unit IdCustomHTTPServer;
ReadLn() cannot raise such an error.
i := RPos(' ', LInputLine, -1); {Do not Localize}
if i = 0 then begin
raise EIdHTTPErrorParsingCommand.Create(RSHTTPErrorParsingCommand);
end;
Which means your client is sending a malformed HTTP request. The first
'GET /login.html HTTP/1.0'
Hense the call to RPos(). The error means there is no space character
anywhere in the line.
Gambit
Loading...