Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2022-09

fpwebfile, indexPageName and query -> 404

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 23 lines
Hello, if I request, e.g. http://localhost:8080 or http://localhost:8080/ fpwebfile returns the document defined as IndexPageName (in my case index.html), but if I request http://localhost:8080?xxx or http://localhost:8080/?xxx I get a 404. That's because TCustomFileModule.GetRequestFIleName with an empty PathInfo uses the URI and thinks that the filename is ?xxx. Maybe the if (Result='') then Result:=ARequest.URI; should be eliminated?

No, it needs to strip the query parameter.

Michael.

Reply by email

Luca Olivetti
to Michael Van Canneyt

El 13/9/22 a les 16:28, Michael Van Canneyt via fpc-pascal ha escrit:

Show quoted text 29 lines
On Tue, 13 Sep 2022, Luca Olivetti via fpc-pascal wrote: > Hello, > > if I request, e.g. > > http://localhost:8080 or http://localhost:8080/ > > fpwebfile returns the document defined as IndexPageName (in my case > index.html), but if I request > > http://localhost:8080?xxx or http://localhost:8080/?xxx > > I get a 404. > > That's because TCustomFileModule.GetRequestFIleName with an empty > PathInfo uses the URI and thinks that the filename is ?xxx. > > Maybe the > > if (Result='') then >  Result:=ARequest.URI; > > > should be eliminated? No, it needs to strip the query parameter.

But that's already in PathInfo:

procedure ParseStartLine(Request : TFPHTTPConnectionRequest; AStartLine
: String);
   Function GetNextWord(Var S : String) : string;
   Var
     P : Integer;
   begin
     P:=Pos(' ',S);
     If (P=0) then
       P:=Length(S)+1;
     Result:=Copy(S,1,P-1);
     Delete(S,1,P);
   end;
Var
   S : String;
   I : Integer;
begin
   if aStartLine='' then
     exit;
   Request.Method:=GetNextWord(AStartLine);
   Request.URL:=GetNextWord(AStartLine);
   S:=Request.URL;
   I:=Pos('?',S);
   if (I>0) then
     S:=Copy(S,1,I-1);
   If (Length(S)>1) and (S[1]'/') then
     S:='/'+S
   else if S='/' then
     S:='';
   Request.PathInfo:=S; <<<<<<<<<<<<

Bye

Luca > > Michael. > _______________________________________________ > fpc-pascal maillist  -  > https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal >

Reply by email

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 32 lines
El 13/9/22 a les 16:28, Michael Van Canneyt via fpc-pascal ha escrit: > > > On Tue, 13 Sep 2022, Luca Olivetti via fpc-pascal wrote: > >> Hello, >> >> if I request, e.g. >> >> http://localhost:8080 or http://localhost:8080/ >> >> fpwebfile returns the document defined as IndexPageName (in my case >> index.html), but if I request >> >> http://localhost:8080?xxx or http://localhost:8080/?xxx >> >> I get a 404. >> >> That's because TCustomFileModule.GetRequestFIleName with an empty PathInfo >> uses the URI and thinks that the filename is ?xxx. >> >> Maybe the >> >> if (Result='') then >>  Result:=ARequest.URI; >> >> >> should be eliminated? > > No, it needs to strip the query parameter. But that's already in PathInfo:

In the HTTP application, yes. In other hosting mechanisms maybe not. When stripping the query param, the result should be empty anyway, and then the default file mechanism will kick in.

Michael.

Reply by email