Java Code Examples for org.springframework.http.HttpMethod#values()
The following examples show how to use
org.springframework.http.HttpMethod#values() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note File: WebContentGenerator.java License: MIT License | 6 votes |
private void initAllowHeader() { Collection<String> allowedMethods; if (this.supportedMethods == null) { allowedMethods = new ArrayList<>(HttpMethod.values().length - 1); for (HttpMethod method : HttpMethod.values()) { if (method != HttpMethod.TRACE) { allowedMethods.add(method.name()); } } } else if (this.supportedMethods.contains(HttpMethod.OPTIONS.name())) { allowedMethods = this.supportedMethods; } else { allowedMethods = new ArrayList<>(this.supportedMethods); allowedMethods.add(HttpMethod.OPTIONS.name()); } this.allowHeader = StringUtils.collectionToCommaDelimitedString(allowedMethods); }
Example 2
Source Project: spring-analysis-note File: FormContentFilterTests.java License: MIT License | 6 votes |
@Test public void wrapPutPatchAndDeleteOnly() throws Exception { for (HttpMethod method : HttpMethod.values()) { MockHttpServletRequest request = new MockHttpServletRequest(method.name(), "/"); request.setContent("foo=bar".getBytes("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) { assertNotSame(request, this.filterChain.getRequest()); } else { assertSame(request, this.filterChain.getRequest()); } } }
Example 3
Source Project: cloudbreak File: Method.java License: Apache License 2.0 | 6 votes |
public static Method build(String methodName) { HttpMethod httpMethod = null; try { httpMethod = HttpMethod.valueOf(methodName.toUpperCase()); } catch (IllegalArgumentException e) { for (HttpMethod checkMethod : HttpMethod.values()) { if (methodName.startsWith(checkMethod.name().toLowerCase())) { httpMethod = checkMethod; break; } } } if (httpMethod == null) { throw new IllegalArgumentException(methodName + " method name should start with http method (get, post, ...)"); } return new Method(httpMethod, methodName); }
Example 4
Source Project: java-technology-stack File: WebContentGenerator.java License: MIT License | 6 votes |
private void initAllowHeader() { Collection<String> allowedMethods; if (this.supportedMethods == null) { allowedMethods = new ArrayList<>(HttpMethod.values().length - 1); for (HttpMethod method : HttpMethod.values()) { if (method != HttpMethod.TRACE) { allowedMethods.add(method.name()); } } } else if (this.supportedMethods.contains(HttpMethod.OPTIONS.name())) { allowedMethods = this.supportedMethods; } else { allowedMethods = new ArrayList<>(this.supportedMethods); allowedMethods.add(HttpMethod.OPTIONS.name()); } this.allowHeader = StringUtils.collectionToCommaDelimitedString(allowedMethods); }
Example 5
Source Project: java-technology-stack File: FormContentFilterTests.java License: MIT License | 6 votes |
@Test public void wrapPutPatchAndDeleteOnly() throws Exception { for (HttpMethod method : HttpMethod.values()) { MockHttpServletRequest request = new MockHttpServletRequest(method.name(), "/"); request.setContent("foo=bar".getBytes("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) { assertNotSame(request, this.filterChain.getRequest()); } else { assertSame(request, this.filterChain.getRequest()); } } }
Example 6
Source Project: lams File: WebContentGenerator.java License: GNU General Public License v2.0 | 6 votes |
private void initAllowHeader() { Collection<String> allowedMethods; if (this.supportedMethods == null) { allowedMethods = new ArrayList<String>(HttpMethod.values().length - 1); for (HttpMethod method : HttpMethod.values()) { if (!HttpMethod.TRACE.equals(method)) { allowedMethods.add(method.name()); } } } else if (this.supportedMethods.contains(HttpMethod.OPTIONS.name())) { allowedMethods = this.supportedMethods; } else { allowedMethods = new ArrayList<String>(this.supportedMethods); allowedMethods.add(HttpMethod.OPTIONS.name()); } this.allowHeader = StringUtils.collectionToCommaDelimitedString(allowedMethods); }
Example 7
Source Project: spring-analysis-note File: FormTag.java License: MIT License | 5 votes |
private void assertHttpMethod(String method) { for (HttpMethod httpMethod : HttpMethod.values()) { if (httpMethod.name().equalsIgnoreCase(method)) { return; } } throw new IllegalArgumentException("Invalid HTTP method: " + method); }
Example 8
Source Project: spring-analysis-note File: ResourceHttpRequestHandlerTests.java License: MIT License | 5 votes |
@Test public void resolvePathWithTraversal() throws Exception { for (HttpMethod method : HttpMethod.values()) { this.request = new MockHttpServletRequest("GET", ""); this.response = new MockHttpServletResponse(); testResolvePathWithTraversal(method); } }
Example 9
Source Project: spring-analysis-note File: ResourceHttpRequestHandlerTests.java License: MIT License | 5 votes |
@Test public void resourceNotFound() throws Exception { for (HttpMethod method : HttpMethod.values()) { this.request = new MockHttpServletRequest("GET", ""); this.response = new MockHttpServletResponse(); resourceNotFound(method); } }
Example 10
Source Project: java-technology-stack File: FormTag.java License: MIT License | 5 votes |
private void assertHttpMethod(String method) { for (HttpMethod httpMethod : HttpMethod.values()) { if (httpMethod.name().equalsIgnoreCase(method)) { return; } } throw new IllegalArgumentException("Invalid HTTP method: " + method); }
Example 11
Source Project: java-technology-stack File: ResourceHttpRequestHandlerTests.java License: MIT License | 5 votes |
@Test public void resolvePathWithTraversal() throws Exception { for (HttpMethod method : HttpMethod.values()) { this.request = new MockHttpServletRequest("GET", ""); this.response = new MockHttpServletResponse(); testResolvePathWithTraversal(method); } }
Example 12
Source Project: java-technology-stack File: ResourceHttpRequestHandlerTests.java License: MIT License | 5 votes |
@Test public void resourceNotFound() throws Exception { for (HttpMethod method : HttpMethod.values()) { this.request = new MockHttpServletRequest("GET", ""); this.response = new MockHttpServletResponse(); resourceNotFound(method); } }
Example 13
Source Project: lams File: FormTag.java License: GNU General Public License v2.0 | 5 votes |
private void assertHttpMethod(String method) { for (HttpMethod httpMethod : HttpMethod.values()) { if (httpMethod.name().equalsIgnoreCase(method)) { return; } } throw new IllegalArgumentException("Invalid HTTP method: " + method); }
Example 14
Source Project: spring4-understanding File: FormTag.java License: Apache License 2.0 | 5 votes |
private void assertHttpMethod(String method) { for (HttpMethod httpMethod : HttpMethod.values()) { if (httpMethod.name().equalsIgnoreCase(method)) { return; } } throw new IllegalArgumentException("Invalid HTTP method: " + method); }
Example 15
Source Project: spring4-understanding File: HttpPutFormContentFilterTests.java License: Apache License 2.0 | 5 votes |
@Test public void wrapPutAndPatchOnly() throws Exception { request.setContent("".getBytes("ISO-8859-1")); for (HttpMethod method : HttpMethod.values()) { request.setMethod(method.name()); filterChain = new MockFilterChain(); filter.doFilter(request, response, filterChain); if (method.equals(HttpMethod.PUT) || method.equals(HttpMethod.PATCH)) { assertNotSame("Should wrap HTTP method " + method, request, filterChain.getRequest()); } else { assertSame("Should not wrap for HTTP method " + method, request, filterChain.getRequest()); } } }
Example 16
Source Project: citrus-admin File: HttpClientConverter.java License: Apache License 2.0 | 5 votes |
/** * Gets the available Http request method names as list. * @return */ private String[] getHttpMethodOptions() { List<String> methodNames = new ArrayList<String>(); for (HttpMethod method : HttpMethod.values()) { methodNames.add(method.name()); } return methodNames.toArray(new String[methodNames.size()]); }
Example 17
Source Project: spring-analysis-note File: ResourceWebHandlerTests.java License: MIT License | 4 votes |
@Test public void testResolvePathWithTraversal() throws Exception { for (HttpMethod method : HttpMethod.values()) { testResolvePathWithTraversal(method); } }
Example 18
Source Project: spring-analysis-note File: ResourceWebHandlerTests.java License: MIT License | 4 votes |
@Test public void resourceNotFound() throws Exception { for (HttpMethod method : HttpMethod.values()) { resourceNotFound(method); } }
Example 19
Source Project: java-technology-stack File: ResourceWebHandlerTests.java License: MIT License | 4 votes |
@Test public void testResolvePathWithTraversal() throws Exception { for (HttpMethod method : HttpMethod.values()) { testResolvePathWithTraversal(method); } }
Example 20
Source Project: java-technology-stack File: ResourceWebHandlerTests.java License: MIT License | 4 votes |
@Test public void resourceNotFound() throws Exception { for (HttpMethod method : HttpMethod.values()) { resourceNotFound(method); } }