Package org.springframework.http.server

Examples of org.springframework.http.server.ServletServerHttpRequest


   * @param webRequest the web request to create an input message from
   * @return the input message
   */
  protected ServletServerHttpRequest createInputMessage(NativeWebRequest webRequest) {
    HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
    return new ServletServerHttpRequest(servletRequest);
  }
View Full Code Here


   * @param servletRequest current HTTP request
   * @return the HttpInputMessage instance to use
   * @throws Exception in case of errors
   */
  protected HttpInputMessage createHttpInputMessage(HttpServletRequest servletRequest) throws Exception {
    return new ServletServerHttpRequest(servletRequest);
  }
View Full Code Here

    if (pageNotFoundLogger.isWarnEnabled()) {
      pageNotFoundLogger.warn("No mapping found for HTTP request with URI [" + getRequestUri(request) +
          "] in DispatcherServlet with name '" + getServletName() + "'");
    }
    if (this.throwExceptionIfNoHandlerFound) {
      ServletServerHttpRequest sshr = new ServletServerHttpRequest(request);
      throw new NoHandlerFoundException(
          sshr.getMethod().name(), sshr.getServletRequest().getRequestURI(), sshr.getHeaders());
    }
    else {
      response.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
  }
View Full Code Here

    private final ServerHttpRequest request;

    RequestSpecificMappingInfoComparator(Comparator<String> pathComparator, HttpServletRequest request) {
      this.pathComparator = pathComparator;
      this.request = new ServletServerHttpRequest(request);
    }
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes", "resource" })
  private ModelAndView handleResponseBody(Object returnValue, ServletWebRequest webRequest)
      throws ServletException, IOException {

    HttpInputMessage inputMessage = new ServletServerHttpRequest(webRequest.getRequest());
    List<MediaType> acceptedMediaTypes = inputMessage.getHeaders().getAccept();
    if (acceptedMediaTypes.isEmpty()) {
      acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
    }
    MediaType.sortByQualityValue(acceptedMediaTypes);
    HttpOutputMessage outputMessage = new ServletServerHttpResponse(webRequest.getResponse());
View Full Code Here

    testException(ex);
  }

  @Test
  public void noHandlerFoundException() {
    ServletServerHttpRequest req = new ServletServerHttpRequest(
        new MockHttpServletRequest("GET","/resource"));
    Exception ex = new NoHandlerFoundException(req.getMethod().toString(),
        req.getServletRequest().getRequestURI(),req.getHeaders());
    testException(ex);
  }
View Full Code Here

    assertEquals("Invalid status code", 400, response.getStatus());
  }

  @Test
  public void handleNoHandlerFoundException() throws Exception {
    ServletServerHttpRequest req = new ServletServerHttpRequest(
        new MockHttpServletRequest("GET","/resource"));
    NoHandlerFoundException ex = new NoHandlerFoundException(req.getMethod().name(),
        req.getServletRequest().getRequestURI(),req.getHeaders());
    ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
    assertNotNull("No ModelAndView returned", mav);
    assertTrue("No Empty ModelAndView returned", mav.isEmpty());
    assertEquals("Invalid status code", 404, response.getStatus());
  }
View Full Code Here

  public void setup() {
    this.body = "body";
    this.contentType = MediaType.TEXT_PLAIN;
    this.converterType = StringHttpMessageConverter.class;
    this.returnType = new MethodParameter(ClassUtils.getMethod(this.getClass(), "handle"), -1);
    this.request = new ServletServerHttpRequest(new MockHttpServletRequest());
    this.response = new ServletServerHttpResponse(new MockHttpServletResponse());
  }
View Full Code Here

    Short shortValue = Short.valueOf((short) 781);

    request.setContent(shortValue.toString().getBytes(
        StringHttpMessageConverter.DEFAULT_CHARSET));

    assertEquals(shortValue, this.converter.read(Short.class, new ServletServerHttpRequest(request)));

    Float floatValue = Float.valueOf(123);

    request.setCharacterEncoding("UTF-16");
    request.setContent(floatValue.toString().getBytes("UTF-16"));

    assertEquals(floatValue, this.converter.read(Float.class, new ServletServerHttpRequest(request)));

    Long longValue = Long.valueOf(55819182821331L);

    request.setCharacterEncoding("UTF-8");
    request.setContent(longValue.toString().getBytes("UTF-8"));

    assertEquals(longValue, this.converter.read(Long.class, new ServletServerHttpRequest(request)));
  }
View Full Code Here

    }

    @Override
    protected HttpInputMessage createHttpInputMessage(NativeWebRequest webRequest) throws Exception {
      HttpServletRequest servletRequest = (HttpServletRequest) webRequest.getNativeRequest();
      return new ServletServerHttpRequest(servletRequest);
    }
View Full Code Here

TOP

Related Classes of org.springframework.http.server.ServletServerHttpRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.