Skip to content
Merged
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 @@ -27,12 +27,19 @@ public interface HttpRequest extends HttpMessage {
SmithyUri uri();

/**
* Get a modifiable version of the request.
* Get a modifiable version of the request, or returns the current request if it's already modifiable.
*
* @return the modifiable request.
* @return the modifiable request or current request.
*/
ModifiableHttpRequest toModifiable();

/**
* Creates a modifiable copy of the request, even if the current request is modifiable.
*
* @return the modifiable copy of this request.
*/
ModifiableHttpRequest toModifiableCopy();

/**
* Creates an unmodifiable copy of the request, or returns it as is if it is already unmodifiable.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public HttpRequest toUnmodifiable() {

@Override
public ModifiableHttpRequest toModifiable() {
return toModifiableCopy();
}

@Override
public ModifiableHttpRequest toModifiableCopy() {
var mod = new ModifiableHttpRequestImpl();
mod.setHttpVersion(httpVersion);
mod.setMethod(method);
Expand Down Expand Up @@ -113,7 +118,7 @@ public HttpRequest build() {
@Override
public ModifiableHttpRequest buildModifiable() {
beforeBuild();
return modifiableHttpRequest.copy();
return modifiableHttpRequest.toModifiableCopy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public interface HttpResponse extends HttpMessage {
*/
ModifiableHttpResponse toModifiable();

/**
* Creates a modifiable copy of the response, even if the current response is modifiable.
*
* @return the modifiable copy of this response.
*/
ModifiableHttpResponse toModifiableCopy();

/**
* Creates an unmodifiable copy of the request, or returns it as is if it is already unmodifiable.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public HttpResponse toUnmodifiable() {

@Override
public ModifiableHttpResponse toModifiable() {
return toModifiableCopy();
}

@Override
public ModifiableHttpResponse toModifiableCopy() {
var mod = new ModifiableHttpResponseImpl();
mod.setHttpVersion(httpVersion);
mod.setStatusCode(statusCode);
Expand Down Expand Up @@ -94,7 +99,7 @@ public HttpResponse build() {

@Override
public ModifiableHttpResponse buildModifiable() {
return modifiableResponse.copy();
return modifiableResponse.toModifiableCopy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,4 @@ default void setUri(URI uri) {
default ModifiableHttpRequest toModifiable() {
return this;
}

/**
* Create a copy of the modifiable request.
*
* @return the standalone copy.
*/
ModifiableHttpRequest copy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public HttpRequest toUnmodifiable() {
}

@Override
public ModifiableHttpRequest copy() {
public ModifiableHttpRequest toModifiableCopy() {
return new ModifiableHttpRequestImpl(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,4 @@ public interface ModifiableHttpResponse extends ModifiableHttpMessage, HttpRespo
default ModifiableHttpResponse toModifiable() {
return this;
}

/**
* Create a copy of the modifiable response.
*
* @return the standalone copy.
*/
ModifiableHttpResponse copy();
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public HttpResponse toUnmodifiable() {
}

@Override
public ModifiableHttpResponse copy() {
public ModifiableHttpResponse toModifiableCopy() {
return new ModifiableHttpResponseImpl(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void modifiableCopyIsIndependent() throws Exception {
.withAddedHeader("foo", "bar")
.buildModifiable();

var copy = modifiable.copy();
var copy = modifiable.toModifiableCopy();
copy.headers().addHeader("foo", "baz");

assertThat(modifiable.headers().allValues("foo"), contains("bar"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void modifiableCopyIsIndependent() {
.withAddedHeader("foo", "bar")
.buildModifiable();

var copy = modifiable.copy();
var copy = modifiable.toModifiableCopy();
copy.headers().addHeader("foo", "baz");

assertThat(modifiable.headers().allValues("foo"), contains("bar"));
Expand Down
Loading