Skip to content

Commit 3d9eee7

Browse files
authored
feat(http): replace getRequestURI() with getServletPath() (#6534)
1 parent 97f1f6f commit 3d9eee7

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

framework/src/main/java/org/tron/core/services/filter/HttpApiAccessFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public void init(FilterConfig filterConfig) {
2626
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
2727
try {
2828
if (request instanceof HttpServletRequest) {
29-
String endpoint = ((HttpServletRequest) request).getRequestURI();
29+
String contextPath = ((HttpServletRequest) request).getContextPath();
30+
String endpoint = contextPath + ((HttpServletRequest) request).getServletPath();
3031
HttpServletResponse resp = (HttpServletResponse) response;
3132

3233
if (isDisabled(endpoint)) {

framework/src/main/java/org/tron/core/services/filter/HttpInterceptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
3434
chain.doFilter(request, response);
3535
return;
3636
}
37-
endpoint = ((HttpServletRequest) request).getRequestURI();
37+
String contextPath = ((HttpServletRequest) request).getContextPath();
38+
endpoint = contextPath + ((HttpServletRequest) request).getServletPath();
3839
CharResponseWrapper responseWrapper = new CharResponseWrapper(
3940
(HttpServletResponse) response);
4041
chain.doFilter(request, responseWrapper);

framework/src/main/java/org/tron/core/services/filter/LiteFnQueryHttpFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public void init(FilterConfig filterConfig) throws ServletException {
110110
@Override
111111
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
112112
FilterChain filterChain) throws IOException, ServletException {
113-
String requestPath = ((HttpServletRequest) servletRequest).getRequestURI();
113+
String contextPath = ((HttpServletRequest) servletRequest).getContextPath();
114+
String requestPath = contextPath + ((HttpServletRequest) servletRequest).getServletPath();
114115
if (chainBaseManager.isLiteNode()
115116
&& !CommonParameter.getInstance().openHistoryQueryWhenLiteFN
116117
&& filterPaths.contains(requestPath)) {

framework/src/main/java/org/tron/core/services/http/RateLimiterServlet.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ protected void service(HttpServletRequest req, HttpServletResponse resp)
9999
if (rateLimiter != null) {
100100
acquireResource = rateLimiter.acquire(runtimeData);
101101
}
102-
String url = Strings.isNullOrEmpty(req.getRequestURI())
103-
? MetricLabels.UNDEFINED : req.getRequestURI();
102+
String contextPath = req.getContextPath();
103+
String url = Strings.isNullOrEmpty(req.getServletPath())
104+
? MetricLabels.UNDEFINED : contextPath + req.getServletPath();
104105
try {
105106
resp.setContentType("application/json; charset=utf-8");
106107

framework/src/main/java/org/tron/core/services/interfaceOnPBFT/http/PBFT/HttpApiOnPBFTService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public class HttpApiOnPBFTService extends HttpService {
172172
public HttpApiOnPBFTService() {
173173
port = Args.getInstance().getPBFTHttpPort();
174174
enable = isFullNode() && Args.getInstance().isPBFTHttpEnable();
175-
contextPath = "/walletpbft/";
175+
contextPath = "/walletpbft";
176176
}
177177

178178
@Override

0 commit comments

Comments
 (0)