View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0030073 | FPC | FCL | public | 2016-04-28 03:17 | 2017-04-07 14:47 |
Reporter | Marcos Douglas | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | i386/x86_64 | OS | Windows | ||
Product Version | 3.1.1 | ||||
Target Version | 3.0.2 | Fixed in Version | 3.1.1 | ||
Summary | 0030073: fcl-web: PATH_INFO variable on Microsoft-IIS | ||||
Description | I have one module: ModuleName= 'pdf' ModuleClass= TPDFModule and two actions: 'act1' 'act2' Browser: http://localhost:2015/fcgitest/pdf/act1 Error: The application encountered the following error: Error: Could not determine HTTP module for request "fcgitest.exe" Stack trace: $004328E3 $00433012 $004323E2 The problem is the PATH_INFO variable. I'm sending a patch to fix this. | ||||
Steps To Reproduce | Just call an URL with module and action. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 33613,34466. | ||||
FPCOldBugId | |||||
FPCTarget | |||||
Attached Files |
|
|
fcl-web-base.patch (3,506 bytes)
Index: packages/fcl-web/src/base/custcgi.pp =================================================================== --- packages/fcl-web/src/base/custcgi.pp (revision 33565) +++ packages/fcl-web/src/base/custcgi.pp (working copy) @@ -180,7 +180,7 @@ { 14: 'SERVER_NAME' } (h:hhServer; v : hvUnknown), { 15: 'SERVER_PORT' } (h:hhUnknown; v : hvServerPort), { 16: 'SERVER_PROTOCOL' } (h:hhUnknown; v : hvUnknown), - { 17: 'SERVER_SOFTWARE' } (h:hhUnknown; v : hvUnknown), + { 17: 'SERVER_SOFTWARE' } (h:hhUnknown; v : hvServerSoftware), { 18: 'HTTP_ACCEPT' } (h:hhAccept; v : hvUnknown), { 19: 'HTTP_ACCEPT_CHARSET' } (h:hhAcceptCharset; v : hvUnknown), { 20: 'HTTP_ACCEPT_ENCODING' } (h:hhAcceptEncoding; v : hvUnknown), @@ -318,7 +318,7 @@ function TCGIRequest.DoGetCGIVar(AVarName : String) : String; begin - GetEnvironmentVariable(AVarName); + Result := GetEnvironmentVariable(AVarName); end; function TCGIRequest.GetCGIVar(Index: integer): String; @@ -349,30 +349,37 @@ end; procedure TCGIRequest.InitFromEnvironment; - - -Var +var I : Integer; - R,V,OV : String; + R,V : string; M : TMap; - begin For I:=1 to CGIVarCount do - begin + begin V:=GetEnvironmentVariable(CGIVarNames[I]); if (V<>'') then - begin + begin M:=MapCgiToHTTP[i]; if M.H<>hhUnknown then SetHeader(M.H,HTTPDecode(V)) else if M.V<>hvUnknown then - begin + begin if M.V<>hvQuery then V:=HTTPDecode(V); SetHTTPVariable(M.V,V) - end; end; end; + end; + + // Microsoft-IIS hack + if Pos('IIS', ServerSoftware) > 0 then + begin + SetHTTPVariable( + hvPathInfo, + StringReplace(PathInfo, ScriptName, '', [rfReplaceAll, rfIgnoreCase]) + ); + end; + R:=UpCase(Method); if (R='POST') or (R='PUT') or (ContentLength>0) then ReadContent; Index: packages/fcl-web/src/base/httpdefs.pp =================================================================== --- packages/fcl-web/src/base/httpdefs.pp (revision 33565) +++ packages/fcl-web/src/base/httpdefs.pp (working copy) @@ -110,7 +110,7 @@ // HTTP related variables. THTTPVariableType = (hvUnknown,hvHTTPVersion, hvMethod, hvCookie, hvSetCookie, hvXRequestedWith, hvPathInfo,hvPathTranslated,hvRemoteAddress,hvRemoteHost,hvScriptName, - hvServerPort,hvURL,hvQuery,hvContent); + hvServerPort,hvURL,hvQuery,hvContent,hvServerSoftware); THTTPVariableTypes = Set of THTTPVariableType; Type @@ -389,6 +389,7 @@ Property RemoteHost : String Index Ord(hvRemoteHost) read GetHTTPVariable Write SetHTTPVariable; Property ScriptName : String Index Ord(hvScriptName) read GetHTTPVariable Write SetHTTPVariable; Property ServerPort : Word Read GetServerPort Write SetServerPort; // Index 30 + Property ServerSoftware : String Index Ord(hvServerSoftware) read GetHTTPVariable Write SetHTTPVariable; Property Method : String Index Ord(hvMethod) read GetHTTPVariable Write SetHTTPVariable; Property URL : String Index Ord(hvURL) read GetHTTPVariable Write SetHTTPVariable; Property Query : String Index Ord(hvQuery) read GetHTTPVariable Write SetHTTPVariable; @@ -956,7 +957,7 @@ (-1, 0,31,11,22,36, 25,26,27,28,29, - 30,32,33,35); + 30,32,33,35,17); begin Result:=High(THTTPVariableType); |
|
Thank you for the patch. I have applied the patch partially. I did not add ServerSoftware to TRequest. It is already defined in TCGIRequest. ServerSoftware is a CGI only variable, and is not part of the HTTP protocol. So, it is only defined in TCGIRequest, not in TRequest. A person that knows he is using CGI/FastCGI only can do a typecast (Request as TCGIRequest) to access additional CGI variables. Please test and close the issue if OK. |
|
Sorry my first long patch. Indeed you're right about ServerSoftware is a CGI only variable, and is not part of the HTTP protocol, of course. But to work propertly you need this second patch — was part of the first one — that I'm attaching. |
|
custcgi.pp.patch (472 bytes)
Index: packages/fcl-web/src/base/custcgi.pp =================================================================== --- packages/fcl-web/src/base/custcgi.pp (revision 33581) +++ packages/fcl-web/src/base/custcgi.pp (working copy) @@ -318,7 +318,7 @@ function TCGIRequest.DoGetCGIVar(AVarName : String) : String; begin - GetEnvironmentVariable(AVarName); + Result := GetEnvironmentVariable(AVarName); end; function TCGIRequest.GetCGIVar(Index: integer): String; |
|
Hm. Very strange that I never had problems with the existing code. Maybe because I work only on 64-bit. Applied your patch in 33613. (I didn't notice this in your first patch, sorry!) |
|
Thanks. |
|
The same problem is occurring when using FastCGI. I think TCGIRequest.InitFromEnvironment is not used by FastCGI module. I'm trying with FPC 3.0.1 (fixes_3_0) and trunk |
|
custfcgi.pp.patch (612 bytes)
Index: packages/fcl-web/src/base/custfcgi.pp =================================================================== --- packages/fcl-web/src/base/custfcgi.pp (revision 34383) +++ packages/fcl-web/src/base/custfcgi.pp (working copy) @@ -354,6 +354,9 @@ else NameValueList.Add(Name+'='+Value) end; + // Microsoft-IIS hack. IIS includes the script name in the PATH_INFO + if Pos('IIS', ServerSoftware) > 0 then + SetHTTPVariable(hvPathInfo,StringReplace(PathInfo, ScriptName, '', [rfReplaceAll, rfIgnoreCase])); end; procedure TFCGIRequest.Log(EventType: TEventType; const Msg: String); |
|
I sent a new patch (custfcgi.pp.patch). Solves my problem, but I don't like this solution because the "IIS hack" now exists in two units. |
|
Applied second patch. Thanks for the patches. |
Date Modified | Username | Field | Change |
---|---|---|---|
2016-04-28 03:17 | Marcos Douglas | New Issue | |
2016-04-28 03:17 | Marcos Douglas | File Added: fcl-web-base.patch | |
2016-04-30 08:11 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2016-04-30 08:11 | Michael Van Canneyt | Status | new => assigned |
2016-04-30 08:32 | Michael Van Canneyt | Fixed in Revision | => 33576 |
2016-04-30 08:32 | Michael Van Canneyt | Note Added: 0092302 | |
2016-04-30 08:32 | Michael Van Canneyt | Status | assigned => resolved |
2016-04-30 08:32 | Michael Van Canneyt | Fixed in Version | => 3.1.1 |
2016-04-30 08:32 | Michael Van Canneyt | Resolution | open => fixed |
2016-04-30 08:32 | Michael Van Canneyt | Target Version | => 3.0.2 |
2016-04-30 16:10 | Marcos Douglas | Note Added: 0092314 | |
2016-04-30 16:10 | Marcos Douglas | Status | resolved => feedback |
2016-04-30 16:10 | Marcos Douglas | Resolution | fixed => reopened |
2016-04-30 16:11 | Marcos Douglas | File Added: custcgi.pp.patch | |
2016-05-02 15:18 | Michael Van Canneyt | Fixed in Revision | 33576 => 33613 |
2016-05-02 15:18 | Michael Van Canneyt | Note Added: 0092337 | |
2016-05-02 15:18 | Michael Van Canneyt | Status | feedback => resolved |
2016-05-02 15:18 | Michael Van Canneyt | Resolution | reopened => fixed |
2016-05-02 19:45 | Marcos Douglas | Note Added: 0092344 | |
2016-05-02 19:45 | Marcos Douglas | Status | resolved => closed |
2016-08-29 05:56 | Marcos Douglas | Note Added: 0094336 | |
2016-08-29 05:56 | Marcos Douglas | Status | closed => feedback |
2016-08-29 05:56 | Marcos Douglas | Resolution | fixed => reopened |
2016-08-29 06:47 | Marcos Douglas | File Added: custfcgi.pp.patch | |
2016-08-29 06:51 | Marcos Douglas | Note Added: 0094338 | |
2016-08-29 06:51 | Marcos Douglas | Status | feedback => assigned |
2016-09-09 08:07 | Michael Van Canneyt | Fixed in Revision | 33613 => 33613,34466. |
2016-09-09 08:07 | Michael Van Canneyt | Note Added: 0094501 | |
2016-09-09 08:07 | Michael Van Canneyt | Status | assigned => resolved |
2016-09-09 08:07 | Michael Van Canneyt | Resolution | reopened => fixed |
2017-04-07 14:47 | Marcos Douglas | Status | resolved => closed |