Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: using Micronaut's Response.getReason instead of javax core Response #1168

Open
wants to merge 1 commit into
base: 5.0.x
Choose a base branch
from
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 @@ -33,7 +33,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -109,8 +108,7 @@ public AwsProxyResponse writeResponse(
if (containerResponse.getAwsProxyRequest().getRequestSource() == AwsProxyRequest.RequestSource.ALB) {
final HttpStatus status = containerResponse.getStatus();
awsProxyResponse.setStatusDescription(
status + " " +
Response.Status.fromStatusCode(status.getCode()).getReasonPhrase());
status + " " + status.getReason());
}

Timer.stop(TIMER_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ class ResponseStatusSpec extends Specification {
handler.close()
}

void "test multi status with alb"() {
given:

def handler = new MicronautLambdaContainerHandler(
ApplicationContext.builder().properties([
'micronaut.security.enabled': false,
'spec.name': 'ResponseStatusSpec'
])
)

AwsProxyRequestBuilder builder = new AwsProxyRequestBuilder('/response-status/multi-status', HttpMethod.GET.toString()).alb()
builder.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN)

when:
def response = handler.proxy(builder.build(), lambdaContext)

then:
response.statusCode == 207

cleanup:
handler.close()
}

void "test optional causes 404"() {
given:

Expand Down Expand Up @@ -164,5 +187,11 @@ class ResponseStatusSpec extends Specification {
void deleteSomething() {
// do nothing
}

@Get(uri = "/multi-status", processes = MediaType.TEXT_PLAIN)
@Status(HttpStatus.MULTI_STATUS)
void multiStatus() {
// do nothing
}
}
}