Package org.springframework.http.server

Examples of org.springframework.http.server.ServletServerHttpRequest


  @SuppressWarnings({ "unchecked", "rawtypes", "resource" })
  protected ModelAndView getModelAndView(ServletWebRequest webRequest, ApiError error)
      throws HttpMessageNotWritableException, IOException {
   
    if (error != null) {
      HttpInputMessage inputMessage = new ServletServerHttpRequest(webRequest.getRequest());
     
      List<MediaType> acceptedMediaTypes = inputMessage.getHeaders().getAccept();
      if (acceptedMediaTypes.isEmpty()) {
        acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
      }
     
      MediaType.sortByQualityValue(acceptedMediaTypes);
View Full Code Here


  @Override
  protected void doFilterInternal(final HttpServletRequest request, HttpServletResponse response,
      FilterChain filterChain) throws ServletException, IOException {

    if (("PUT".equals(request.getMethod()) || "PATCH".equals(request.getMethod())) && isFormContentType(request)) {
      HttpInputMessage inputMessage = new ServletServerHttpRequest(request) {
        @Override
        public InputStream getBody() throws IOException {
          return request.getInputStream();
        }
      };
View Full Code Here

  @Override
  protected <T> Object readWithMessageConverters(NativeWebRequest webRequest,
      MethodParameter methodParam,  Type paramType) throws IOException, HttpMediaTypeNotSupportedException {

    final HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
    HttpInputMessage inputMessage = new ServletServerHttpRequest(servletRequest);

    RequestBody annot = methodParam.getParameterAnnotation(RequestBody.class);
    if (!annot.required()) {
      InputStream inputStream = inputMessage.getBody();
      if (inputStream == null) {
        return null;
      }
      else if (inputStream.markSupported()) {
        inputStream.mark(1);
        if (inputStream.read() == -1) {
          return null;
        }
        inputStream.reset();
      }
      else {
        final PushbackInputStream pushbackInputStream = new PushbackInputStream(inputStream);
        int b = pushbackInputStream.read();
        if (b == -1) {
          return null;
        }
        else {
          pushbackInputStream.unread(b);
        }
        inputMessage = new ServletServerHttpRequest(servletRequest) {
          @Override
          public InputStream getBody() throws IOException {
            // Form POST should not get here
            return pushbackInputStream;
          }
View Full Code Here

  @Override
  protected void doFilterInternal(final HttpServletRequest request, HttpServletResponse response,
      FilterChain filterChain) throws ServletException, IOException {

    if ("PUT".equals(request.getMethod()) && isFormContentType(request)) {
      HttpInputMessage inputMessage = new ServletServerHttpRequest(request) {
        @Override
        public InputStream getBody() throws IOException {
          return request.getInputStream();
        }
      };
View Full Code Here

   * @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

   */
  protected <T> void writeWithMessageConverters(T returnValue,
                          MethodParameter returnType,
                          NativeWebRequest webRequest)
      throws IOException, HttpMediaTypeNotAcceptableException {
    ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
    ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);
    writeWithMessageConverters(returnValue, returnType, inputMessage, outputMessage);
  }
View Full Code Here

    if (returnValue == null) {
      return;
    }

    ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
    ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);

    Assert.isInstanceOf(HttpEntity.class, returnValue);
    HttpEntity<?> responseEntity = (HttpEntity<?>) returnValue;
    if (responseEntity instanceof ResponseEntity) {
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")
  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

   */
  protected <T> void writeWithMessageConverters(T returnValue,
                          MethodParameter returnType,
                          NativeWebRequest webRequest)
      throws IOException, HttpMediaTypeNotAcceptableException {
    ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
    ServletServerHttpResponse outputMessage = createOutputMessage(webRequest);
    writeWithMessageConverters(returnValue, returnType, inputMessage, outputMessage);
  }
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.