You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using spring-cloud-function-adapter-gcp with a function that responds with a Message object to an HTTP trigger, the response's Content-Type header is not set according to the Message's corresponding header as presumably intended. It is rather overridden by the original request's content type.
It seems like PR #719 was originally meant to fix that the content type was incorrectly referenced by key contentType rather than the correct Content-Type, but actually it did not resolve that issue. Instead, it introduced the aforementioned bug. So now, the response contains two headers contentType and Content-Type which both do not reflect the value passed as message header.
Versions used:
Java 21
Spring Boot 3.3.2
Spring Cloud 2023.0.3
Spring Cloud Function & Spring Cloud Function Adapter GCP 4.1.3
Google Function Maven Plugin 0.11.0
Steps to reproduce
To reproduce the bug in a minimal setting, I used spring initializr with these settings to create a blank Spring Boot Application and replaced the contents of src/main/java/com/example/demo/DemoApplication.java with the following code:
Also, the Maven manifest had to be extended to include the Spring Cloud Function and Spring Cloud Function GCP Adapter, as well as Google's Function Maven plugin to run the function:
It is probably also worth mentioning that the current behavior differs from the default behavior when using spring-cloud-starter-function-web instead of the GCP adapter to run the function. In this case, only Content-Type: application/problem+json results from the example above.
Describe the bug
When using
spring-cloud-function-adapter-gcp
with a function that responds with aMessage
object to an HTTP trigger, the response'sContent-Type
header is not set according to theMessage
's corresponding header as presumably intended. It is rather overridden by the original request's content type.It seems like PR #719 was originally meant to fix that the content type was incorrectly referenced by key
contentType
rather than the correctContent-Type
, but actually it did not resolve that issue. Instead, it introduced the aforementioned bug. So now, the response contains two headerscontentType
andContent-Type
which both do not reflect the value passed as message header.Versions used:
Steps to reproduce
To reproduce the bug in a minimal setting, I used spring initializr with these settings to create a blank Spring Boot Application and replaced the contents of
src/main/java/com/example/demo/DemoApplication.java
with the following code:Also, the Maven manifest had to be extended to include the Spring Cloud Function and Spring Cloud Function GCP Adapter, as well as Google's Function Maven plugin to run the function:
Finally, the Function Maven Plugin need a pointer to the application's main class in
src/main/resources/META-INF/MANIFEST.MF
:After starting the application using
./mvnw function:run
the function is now ready to accept requests:Expected behavior
The
Content-Type
header of the resulting response should have the valueapplication/problem+json
and no header namedcontentType
should exist.Actual behavior
The request above results in the following response:
Both headers
Content-Type
andcontentType
exist and they both carry the unexpected valueapplication/json
.If no content type is given with the request (
curl -v localhost:8080 -d '"Hello World"'
) then the response looks as follows:Here the headers
Content-Type
andcontentType
still exist simultaneously, and they even carry different values.The text was updated successfully, but these errors were encountered: