Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
topframe committed Mar 18, 2024
1 parent ec4d336 commit 5517552
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public String getContextPath() {

@Override
public boolean isRequestWithContextPath() {
return (contextPath != null && translet != null && translet.getRequestName().startsWith(contextPath));
Assert.state(adapted, "Not yet adapted");
return (contextPath != null && translet.getRequestName().startsWith(contextPath));
}

/**
Expand Down Expand Up @@ -226,6 +227,10 @@ public void prepare(String requestName, MethodType requestMethod, TransletRule t
}
}

protected boolean isAdapted() {
return adapted;
}

protected void adapt() throws AdapterException {
}

Expand Down
13 changes: 13 additions & 0 deletions web/src/main/java/com/aspectran/web/activity/WebActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.aspectran.core.context.rule.type.MethodType;
import com.aspectran.core.support.i18n.locale.LocaleChangeInterceptor;
import com.aspectran.core.support.i18n.locale.LocaleResolver;
import com.aspectran.utils.Assert;
import com.aspectran.utils.StringUtils;
import com.aspectran.web.activity.request.MultipartFormDataParser;
import com.aspectran.web.activity.request.MultipartRequestParseException;
Expand Down Expand Up @@ -70,6 +71,18 @@ public WebActivity(ActivityContext context, String contextPath,
this.response = response;
}

@Override
public boolean isRequestWithContextPath() {
Assert.state(isAdapted(), "Not yet adapted");
if (getContextPath() != null) {
String forwardedPath = getRequestAdapter().getHeader(HttpHeaders.X_FORWARDED_PATH);
if (forwardedPath != null) {
return (getContextPath().equals(forwardedPath) || forwardedPath.startsWith(getContextPath() + "/"));
}
}
return super.isRequestWithContextPath();
}

@Override
public void prepare(String requestName, MethodType requestMethod, TransletRule transletRule)
throws ActivityPrepareException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,9 @@ public interface HttpHeaders {
*/
String X_FORWARDED_PROTO = "X-Forwarded-Proto";

/**
* Contains the original path that the client requested.
*/
String X_FORWARDED_PATH = "X-Forwarded-Path";

}

0 comments on commit 5517552

Please sign in to comment.