polishing
This commit is contained in:
@@ -318,7 +318,7 @@ public class HttpHeaders implements MultiValueMap<String, String> {
|
||||
Assert.isTrue(eTag.startsWith("\"") || eTag.startsWith("W/"), "Invalid eTag, does not start with W/ or \"");
|
||||
Assert.isTrue(eTag.endsWith("\""), "Invalid eTag, does not end with \"");
|
||||
}
|
||||
set(ETAG, eTag);
|
||||
set(ETAG, eTag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,6 +86,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
|
||||
private List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
|
||||
|
||||
|
||||
public FormHttpMessageConverter() {
|
||||
this.supportedMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
|
||||
this.supportedMediaTypes.add(MediaType.MULTIPART_FORM_DATA);
|
||||
@@ -97,13 +98,6 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
this.partConverters.add(new ResourceHttpMessageConverter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message body converter. Such a converters is used to convert objects to MIME parts.
|
||||
*/
|
||||
public final void addPartConverter(HttpMessageConverter<?> partConverter) {
|
||||
Assert.notNull(partConverter, "'partConverter' must not be NULL");
|
||||
this.partConverters.add(partConverter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message body converters to use. These converters are used to convert objects to MIME parts.
|
||||
@@ -113,6 +107,14 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
this.partConverters = partConverters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message body converter. Such a converters is used to convert objects to MIME parts.
|
||||
*/
|
||||
public final void addPartConverter(HttpMessageConverter<?> partConverter) {
|
||||
Assert.notNull(partConverter, "'partConverter' must not be NULL");
|
||||
this.partConverters.add(partConverter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the character set used for writing form data.
|
||||
*/
|
||||
@@ -160,7 +162,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
}
|
||||
|
||||
public List<MediaType> getSupportedMediaTypes() {
|
||||
return Collections.unmodifiableList(supportedMediaTypes);
|
||||
return Collections.unmodifiableList(this.supportedMediaTypes);
|
||||
}
|
||||
|
||||
public MultiValueMap<String, String> read(Class<? extends MultiValueMap<String, ?>> clazz,
|
||||
@@ -325,8 +327,9 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a multipart boundary. <p>Default implementation returns a random boundary. Can be overridden in
|
||||
* subclasses.
|
||||
* Generate a multipart boundary.
|
||||
* <p>The default implementation returns a random boundary.
|
||||
* Can be overridden in subclasses.
|
||||
*/
|
||||
protected byte[] generateMultipartBoundary() {
|
||||
byte[] boundary = new byte[rnd.nextInt(11) + 30];
|
||||
@@ -337,10 +340,10 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the filename of the given multipart part. This value will be used for the {@code Content-Disposition} header.
|
||||
* <p>Default implementation returns {@link Resource#getFilename()} if the part is a {@code Resource}, and {@code null}
|
||||
* in other cases. Can be overridden in subclasses.
|
||||
*
|
||||
* Return the filename of the given multipart part. This value will be used for the
|
||||
* {@code Content-Disposition} header.
|
||||
* <p>The default implementation returns {@link Resource#getFilename()} if the part is a
|
||||
* {@code Resource}, and {@code null} in other cases. Can be overridden in subclasses.
|
||||
* @param part the part to determine the file name for
|
||||
* @return the filename, or {@code null} if not known
|
||||
*/
|
||||
@@ -354,6 +357,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter<MultiValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of {@link org.springframework.http.HttpOutputMessage} used for writing multipart data.
|
||||
*/
|
||||
|
||||
@@ -56,21 +56,22 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
|
||||
private HttpHeaders headers;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest}
|
||||
*
|
||||
* @param servletRequest the HttpServletRequest
|
||||
* Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest}.
|
||||
* @param servletRequest the servlet request
|
||||
*/
|
||||
public ServletServerHttpRequest(HttpServletRequest servletRequest) {
|
||||
Assert.notNull(servletRequest, "'servletRequest' must not be null");
|
||||
this.servletRequest = servletRequest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@code HttpServletRequest} this object is based on.
|
||||
*/
|
||||
public HttpServletRequest getServletRequest() {
|
||||
return servletRequest;
|
||||
return this.servletRequest;
|
||||
}
|
||||
|
||||
public HttpMethod getMethod() {
|
||||
@@ -79,9 +80,9 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
||||
|
||||
public URI getURI() {
|
||||
try {
|
||||
return new URI(servletRequest.getScheme(), null, servletRequest.getServerName(),
|
||||
servletRequest.getServerPort(), servletRequest.getRequestURI(), servletRequest.getQueryString(),
|
||||
null);
|
||||
return new URI(this.servletRequest.getScheme(), null, this.servletRequest.getServerName(),
|
||||
this.servletRequest.getServerPort(), this.servletRequest.getRequestURI(),
|
||||
this.servletRequest.getQueryString(), null);
|
||||
}
|
||||
catch (URISyntaxException ex) {
|
||||
throw new IllegalStateException("Could not get HttpServletRequest URI: " + ex.getMessage(), ex);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
|
||||
|
||||
/**
|
||||
* Construct a new instance of the ServletServerHttpResponse based on the given {@link HttpServletResponse}.
|
||||
* @param servletResponse the HTTP Servlet response
|
||||
* @param servletResponse the servlet response
|
||||
*/
|
||||
public ServletServerHttpResponse(HttpServletResponse servletResponse) {
|
||||
Assert.notNull(servletResponse, "'servletResponse' must not be null");
|
||||
@@ -52,10 +52,10 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@code HttpServletResponse} this object is based on.
|
||||
* Return the {@code HttpServletResponse} this object is based on.
|
||||
*/
|
||||
public HttpServletResponse getServletResponse() {
|
||||
return servletResponse;
|
||||
return this.servletResponse;
|
||||
}
|
||||
|
||||
public void setStatusCode(HttpStatus status) {
|
||||
@@ -63,7 +63,7 @@ public class ServletServerHttpResponse implements ServerHttpResponse {
|
||||
}
|
||||
|
||||
public HttpHeaders getHeaders() {
|
||||
return headersWritten ? HttpHeaders.readOnlyHttpHeaders(headers) : this.headers;
|
||||
return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers);
|
||||
}
|
||||
|
||||
public OutputStream getBody() throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user