Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit a2d469b

Browse files
committed
set servlet attribute for method override only
1 parent e102033 commit a2d469b

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

endpoints-control/src/main/java/com/google/api/control/ConfigFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class ConfigFilter implements Filter {
6161
static final String REPORTING_ATTRIBUTE = ATTRIBUTE_ROOT + ".reporting";
6262

6363
@VisibleForTesting
64-
static final String HTTP_METHOD_ATTRIBUTE = ATTRIBUTE_ROOT + ".http_method";
64+
static final String HTTP_METHOD_OVERRIDE_ATTRIBUTE = ATTRIBUTE_ROOT + ".http_method_override";
6565

6666
private Service theService;
6767
private Loader loader;
@@ -118,8 +118,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
118118

119119
// Determine if service control is required
120120
String uri = httpRequest.getRequestURI();
121-
String method = getRequestMethod(httpRequest);
122-
httpRequest.setAttribute(HTTP_METHOD_ATTRIBUTE, method);
121+
String method = getRequestMethodOverride(httpRequest);
122+
httpRequest.setAttribute(HTTP_METHOD_OVERRIDE_ATTRIBUTE, method);
123123
Info info = registry.lookup(method, uri);
124124
if (info != null) {
125125
httpRequest.setAttribute(METHOD_INFO_ATTRIBUTE, info);
@@ -185,7 +185,7 @@ public static MethodRegistry.Info getMethodInfo(ServletRequest req) {
185185
*/
186186
public static String getRealHttpMethod(ServletRequest req) {
187187
HttpServletRequest httpRequest = (HttpServletRequest) req;
188-
String method = (String) httpRequest.getAttribute(HTTP_METHOD_ATTRIBUTE);
188+
String method = (String) httpRequest.getAttribute(HTTP_METHOD_OVERRIDE_ATTRIBUTE);
189189
if (method != null) {
190190
return method;
191191
}
@@ -197,7 +197,7 @@ public void destroy() {
197197
// unused
198198
}
199199

200-
private static String getRequestMethod(HttpServletRequest request) {
200+
private static String getRequestMethodOverride(HttpServletRequest request) {
201201
Enumeration headerNames = request.getHeaderNames();
202202
String methodOverride = null;
203203
while (headerNames.hasMoreElements()) {
@@ -207,6 +207,6 @@ private static String getRequestMethod(HttpServletRequest request) {
207207
break;
208208
}
209209
}
210-
return methodOverride != null ? methodOverride.toUpperCase() : request.getMethod();
210+
return methodOverride != null ? methodOverride.toUpperCase() : null;
211211
}
212212
}

0 commit comments

Comments
 (0)