Skip to content

Commit

Permalink
fix routing - remove script name from request uri
Browse files Browse the repository at this point in the history
  • Loading branch information
s2x committed Jan 27, 2015
1 parent dca3944 commit 05eb28e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 11 deletions.
10 changes: 5 additions & 5 deletions .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1537295155" moduleId="org.eclipse.cdt.core.settings" name="Build (GNU)">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1537295155" name="Build (GNU)" parent="org.eclipse.linuxtools.cdt.autotools.core.configuration.build">
<folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1537295155." name="/" resourcePath="">
<toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.716718361" name="GNU Autotools Toolchain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain">
<targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.212784029" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform"/>
<builder arguments="-j8" command="make" id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.2082580609" keepEnvironmentInBuildfile="false" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
<builder arguments="-j4" autoBuildTarget="" cleanBuildTarget="" command="make" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.2082580609" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.209936929" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure">
<option id="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name.470600626" name="Name" superClass="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name" value="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.1537295155" valueType="string"/>
</tool>
Expand Down Expand Up @@ -47,10 +47,10 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<configuration configurationName="Build (GNU)">
<resource resourceType="PROJECT" workspacePath="/ccframework"/>
</configuration>
<configuration configurationName="Build (GNU)">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/ccframework"/>
</configuration>
</storageModule>
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Makefile
/po/stamp-it
/libtool
/stamp-h1

/src/test/query_test
#anjuta
.anjuta/
.anjuta_sym_db.db
Expand All @@ -34,3 +34,4 @@ Makefile
*.dirstamp
*.pc

/config.h.in~
1 change: 1 addition & 0 deletions src/ccframework/ccApp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ccResponse *ccApp::processRequest(FCGX_Request fcgi_request) {
ctemplate::TemplateCache::LAZY_RELOAD);

}

//proces fastcgi headers
this->request = new ccRequest(fcgi_request);

Expand Down
3 changes: 1 addition & 2 deletions src/ccframework/router/ccPregRoute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ bool ccPregRoute::match(ccRequest *request) {

this->request_params.clear();

std::string request_uri = request->getEnvParamter("REDIRECT_URL",
request->getEnvParamter("REQUEST_URI"));
std::string request_uri = this->getFixedRequestUri(request);
request_uri = request_uri.substr(0, request_uri.find_first_of("?"));

rc = pcre_exec(this->re, NULL, request_uri.c_str(), request_uri.length(), 0,
Expand Down
19 changes: 19 additions & 0 deletions src/ccframework/router/ccRoute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ std::string ccRoute::getUrl(std::map<std::string, std::string> params) {
return this->pattern;
}

std::string ccRoute::getFixedRequestUri(ccRequest* request) {
std::string request_uri = request->getEnvParamter("REDIRECT_URL",
request->getEnvParamter("REQUEST_URI"));
std::string script_name = request->getEnvParamter("SCRIPT_NAME");


if (script_name!="") {
if (request_uri.find(script_name)==0) {
request_uri = request_uri.substr(script_name.length());
}
}

if (request_uri.find("/") == std::string::npos) {
request_uri = "/"+request_uri;
}

return request_uri;
}

} /* namespace ccFramework */


7 changes: 4 additions & 3 deletions src/ccframework/router/ccStaticRoute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
namespace ccFramework {

bool ccStaticRoute::match(ccRequest* request) {

this->request_params.clear();
std::string request_uri = request->getEnvParamter("REDIRECT_URL",
request->getEnvParamter("REQUEST_URI"));
request_uri = request_uri.substr(0, request_uri.find_first_of("?"));
std::string request_uri = this->getFixedRequestUri(request);

request_uri = request_uri.substr(0, request_uri.find_first_of("?"));

if (request_uri.compare(this->pattern)==0) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/include/ccframework/ccRoute.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ccRoute {

virtual bool match(ccRequest *request);

std::string getFixedRequestUri(ccRequest* request);

//if is active route then get paramters
bool hasRouteParameter(std::string name);
Expand Down

0 comments on commit 05eb28e

Please sign in to comment.