Java Code Examples for org.springframework.http.MediaType#toString()
The following examples show how to use
org.springframework.http.MediaType#toString() .
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 File: ContractExchangeHandler.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
@Override public ContentTypeHeader contentTypeHeader() { MediaType contentType = this.result.getRequestHeaders().getContentType(); if (contentType == null) { return null; } return new ContentTypeHeader(contentType.toString()); }
Example 2
Source File: MockHttpServletRequestBuilder.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Add all headers to the request. Values are always added. * @param httpHeaders the headers and values to add */ public MockHttpServletRequestBuilder headers(HttpHeaders httpHeaders) { MediaType mediaType = httpHeaders.getContentType(); if (mediaType != null) { this.contentType = mediaType.toString(); } for (String name : httpHeaders.keySet()) { Object[] values = ObjectUtils.toObjectArray(httpHeaders.get(name).toArray()); addToMultiValueMap(this.headers, name, values); } return this; }
Example 3
Source File: MockHttpServletRequestBuilder.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Add a header to the request. Values are always added. * @param name the header name * @param values one or more header values */ public MockHttpServletRequestBuilder header(String name, Object... values) { if ("Content-Type".equalsIgnoreCase(name)) { List<MediaType> mediaTypes = MediaType.parseMediaTypes(StringUtils.arrayToCommaDelimitedString(values)); this.contentType = MediaType.toString(mediaTypes); } addToMultiValueMap(this.headers, name, values); return this; }
Example 4
Source File: GlobalControllerAdvice.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@ExceptionHandler(HttpMediaTypeNotSupportedException.class) @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) public ResponseEntity<ErrorMessage> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex ) { String unsupported = "Unsupported content type: " + ex.getContentType(); String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); }
Example 5
Source File: GlobalControllerAdvice.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@ExceptionHandler(HttpMediaTypeNotSupportedException.class) @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) public ResponseEntity<ErrorMessage> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex ) { String unsupported = "Unsupported content type: " + ex.getContentType(); String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); }
Example 6
Source File: GlobalControllerAdvice.java From springdoc-openapi with Apache License 2.0 | 5 votes |
@ExceptionHandler(HttpMediaTypeNotSupportedException.class) @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) public ResponseEntity<ErrorMessage> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex ) { String unsupported = "Unsupported content type: " + ex.getContentType(); String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); }
Example 7
Source File: MockPart.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public String getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? contentType.toString() : null); }
Example 8
Source File: SpringHttpRamlMessage.java From raml-tester with Apache License 2.0 | 4 votes |
protected String contentTypeOf(HttpHeaders headers) { final MediaType contentType = headers.getContentType(); return contentType == null ? null : contentType.toString(); }
Example 9
Source File: FormHttpMessageConverterTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public String getContentType() { MediaType type = this.outputMessage.getHeaders().getContentType(); return (type != null ? type.toString() : null); }
Example 10
Source File: HttpComponentsStreamingClientHttpRequest.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public Header getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? new BasicHeader("Content-Type", contentType.toString()) : null); }
Example 11
Source File: HttpComponentsStreamingClientHttpRequest.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public Header getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? new BasicHeader("Content-Type", contentType.toString()) : null); }
Example 12
Source File: MockPart.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public String getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? contentType.toString() : null); }
Example 13
Source File: FormHttpMessageConverterTests.java From java-technology-stack with MIT License | 4 votes |
@Override public String getContentType() { MediaType type = this.outputMessage.getHeaders().getContentType(); return (type != null ? type.toString() : null); }
Example 14
Source File: HttpComponentsStreamingClientHttpRequest.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public Header getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? new BasicHeader("Content-Type", contentType.toString()) : null); }
Example 15
Source File: JettyClientHttpRequest.java From java-technology-stack with MIT License | 4 votes |
private String getContentType() { MediaType contentType = getHeaders().getContentType(); return contentType != null ? contentType.toString() : MediaType.APPLICATION_OCTET_STREAM_VALUE; }
Example 16
Source File: HttpComponentsStreamingClientHttpRequest.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public Header getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? new BasicHeader("Content-Type", contentType.toString()) : null); }
Example 17
Source File: MockPart.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public String getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? contentType.toString() : null); }
Example 18
Source File: FormHttpMessageConverterTests.java From spring-analysis-note with MIT License | 4 votes |
@Override public String getContentType() { MediaType type = this.outputMessage.getHeaders().getContentType(); return (type != null ? type.toString() : null); }
Example 19
Source File: MockPart.java From spring-analysis-note with MIT License | 4 votes |
@Override @Nullable public String getContentType() { MediaType contentType = this.headers.getContentType(); return (contentType != null ? contentType.toString() : null); }
Example 20
Source File: JettyClientHttpRequest.java From spring-analysis-note with MIT License | 4 votes |
private String getContentType() { MediaType contentType = getHeaders().getContentType(); return contentType != null ? contentType.toString() : MediaType.APPLICATION_OCTET_STREAM_VALUE; }