[fpc-pascal] CustHttpApp again, error: "Missing HTTP protocol version in request"

silvioprog silvioprog at gmail.com
Fri Apr 25 00:11:11 CEST 2014


Hello,

I've tested the CustHttpApp unit in new released FPC 2.6.4 on Windows, and
the error "Missing HTTP protocol version in request" still continues.

I'll show detailed steps (including my tools) to reproduce it:

1. on Windows (I'm using 8), download and install the latest Lazarus/FPC
version: "
http://downloads.sourceforge.net/project/lazarus/Lazarus%20Windows%2032%20bits/Lazarus%201.2.2/lazarus-1.2.2-fpc-2.6.4-win32.exe
";
2. download this source code (the project to reproduce the bug) from link "
https://www.dropbox.com/s/rmfitgh7b58cf1g/es_bug.zip" or in attachment;
3. in "Tools | Options ..." menu, got to the "Debugger > Language
Exceptions" page, and check the "Notify on Lazarus Exceptions" option;
4. run the project with F9 (notice that I left a breakpoint);
5. using the "Advanced REST client" Chrome plugin "
https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo",
fill the URL with "http://localhost:1025" and click in "Send" button;
6. push F9 until the Lazarus exits from breakpoint;
7. wait a few moments, that Lazarus will go to the breakpoint after some
secounds;


When Lazarus go to the breakpoint again, push F8 several times, and notice
that in line 363, the "R" variable will receive the zero value:

...
  Procedure FillBuffer;

  Var
    R : Integer;

  begin
    SetLength(FBuffer,ReadBufLen);
    r:=FSocket.Read(FBuffer[1],ReadBufLen); <<< HERE!
    If r<0 then
      Raise EHTTPServer.Create(SErrReadingSocket);
    if (r<ReadBuflen) then
      SetLength(FBuffer,r);
  end;
...

And the FBuffer will be empty, so in line 485, the "S" variable will be
empty:

...
Var
  S : String;

begin
  Request.Method:=GetNextWord(AStartLine);
  Request.URL:=GetNextWord(AStartLine);
  Request.PathInfo:=Request.URL;
  S:=GetNextWord(AStartLine); <<< HERE!
  If (Pos('HTTP/',S)<>1) then
    Raise Exception.Create(SErrMissingProtocol);
  Delete(S,1,5);
  Request.ProtocolVersion:=trim(S);
end;
...

Causing the related error.

Thanks and sorry for the long e-mail!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140424/38ec2a92/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: es_bug.zip
Type: application/zip
Size: 2144 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140424/38ec2a92/attachment.zip>


More information about the fpc-pascal mailing list