use of cn.taketoday.http.HttpMethod in project today-infrastructure by TAKETODAY.
the class ResourceHttpRequestHandlerTests method resourceNotFound.
@Test
public void resourceNotFound() throws Exception {
for (HttpMethod method : HttpMethod.values()) {
this.request = new MockHttpServletRequest("GET", "");
this.response = new MockHttpServletResponse();
resourceNotFound(method);
}
}
use of cn.taketoday.http.HttpMethod in project today-infrastructure by TAKETODAY.
the class ResourceHttpRequestHandlerTests method resolvePathWithTraversal.
@Test
@DisabledOnOs(OS.WINDOWS)
public void resolvePathWithTraversal() throws Exception {
for (HttpMethod method : HttpMethod.values()) {
this.request = new MockHttpServletRequest("GET", "");
this.response = new MockHttpServletResponse();
requestContext = new ServletRequestContext(null, request, response);
testResolvePathWithTraversal(method);
}
}
use of cn.taketoday.http.HttpMethod in project today-infrastructure by TAKETODAY.
the class FormContentFilterTests method wrapPutPatchAndDeleteOnly.
@Test
public void wrapPutPatchAndDeleteOnly() throws Exception {
for (HttpMethod method : HttpMethod.values()) {
MockHttpServletRequest request = new MockHttpServletRequest(method.name(), "/");
request.setContent("foo=bar".getBytes(StandardCharsets.ISO_8859_1));
request.setContentType("application/x-www-form-urlencoded; charset=ISO-8859-1");
this.filterChain = new MockFilterChain();
this.filter.doFilter(request, this.response, this.filterChain);
if (method == HttpMethod.PUT || method == HttpMethod.PATCH || method == HttpMethod.DELETE) {
assertThat(this.filterChain.getRequest()).isNotSameAs(request);
} else {
assertThat(this.filterChain.getRequest()).isSameAs(request);
}
}
}
use of cn.taketoday.http.HttpMethod in project today-infrastructure by TAKETODAY.
the class RequestMethodsRequestCondition method matchPreFlight.
/**
* On a pre-flight request match to the would-be, actual request.
* Hence empty conditions is a match, otherwise try to match to the HTTP
* method in the "Access-Control-Request-Method" header.
*/
@Nullable
private RequestMethodsRequestCondition matchPreFlight(RequestContext request) {
if (getMethods().isEmpty()) {
return this;
}
HttpHeaders headers = request.getHeaders();
HttpMethod expectedMethod = headers.getAccessControlRequestMethod();
// TODO expectedMethod maybe null
Assert.state(expectedMethod != null, "No Access-Control-Request-Method Header");
return matchRequestMethod(expectedMethod);
}
use of cn.taketoday.http.HttpMethod in project today-infrastructure by TAKETODAY.
the class HttpRequestMethodNotSupportedException method getSupportedHttpMethods.
/**
* Return the actually supported HTTP methods as {@link HttpMethod} instances,
* or {@code null} if not known.
*/
@Nullable
public Set<HttpMethod> getSupportedHttpMethods() {
if (this.supportedMethods == null) {
return null;
}
Set<HttpMethod> supportedMethods = new LinkedHashSet<>(this.supportedMethods.length);
for (String value : this.supportedMethods) {
HttpMethod method = HttpMethod.valueOf(value);
supportedMethods.add(method);
}
return supportedMethods;
}
Aggregations