Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public DefaultResponseCreator body(Resource resource) {
/**
* Set the {@code Content-Type} header.
*/
public DefaultResponseCreator contentType(MediaType mediaType) {
public DefaultResponseCreator contentType(@Nullable MediaType mediaType) {
this.headers.setContentType(mediaType);
return this;
}

/**
* Set the {@code Location} header.
*/
public DefaultResponseCreator location(URI location) {
public DefaultResponseCreator location(@Nullable URI location) {
this.headers.setLocation(location);
return this;
}
Expand All @@ -123,7 +123,7 @@ public DefaultResponseCreator location(URI location) {
* Add a response header with one or more values.
* @since 6.0
*/
public DefaultResponseCreator header(String name, String ... headerValues) {
public DefaultResponseCreator header(String name, @Nullable String... headerValues) {
for (String headerValue : headerValues) {
this.headers.add(name, headerValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public static DefaultResponseCreator withSuccess() {
* @param contentType the type of the content (may be {@code null})
*/
public static DefaultResponseCreator withSuccess(String body, @Nullable MediaType contentType) {
DefaultResponseCreator creator = new DefaultResponseCreator(HttpStatus.OK).body(body);
return (contentType != null ? creator.contentType(contentType) : creator);
return new DefaultResponseCreator(HttpStatus.OK).body(body).contentType(contentType);
}

/**
Expand All @@ -64,8 +63,7 @@ public static DefaultResponseCreator withSuccess(String body, @Nullable MediaTyp
* @param contentType the type of the content (may be {@code null})
*/
public static DefaultResponseCreator withSuccess(byte[] body, @Nullable MediaType contentType) {
DefaultResponseCreator creator = new DefaultResponseCreator(HttpStatus.OK).body(body);
return (contentType != null ? creator.contentType(contentType) : creator);
return new DefaultResponseCreator(HttpStatus.OK).body(body).contentType(contentType);
}

/**
Expand All @@ -74,8 +72,7 @@ public static DefaultResponseCreator withSuccess(byte[] body, @Nullable MediaTyp
* @param contentType the type of the content (may be {@code null})
*/
public static DefaultResponseCreator withSuccess(Resource body, @Nullable MediaType contentType) {
DefaultResponseCreator creator = new DefaultResponseCreator(HttpStatus.OK).body(body);
return (contentType != null ? creator.contentType(contentType) : creator);
return new DefaultResponseCreator(HttpStatus.OK).body(body).contentType(contentType);
}

/**
Expand Down