diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 4c5a660619..a5fcfaa4cb 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -32,7 +32,7 @@ jobs: - name: Create lib directory if not exists run: mkdir -p ballerina/lib - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master + uses: aquasecurity/trivy-action@0.23.0 with: scan-type: 'rootfs' scan-ref: '/github/workspace/ballerina/lib' diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 9f37c1a406..19f290fe04 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -29,7 +29,7 @@ jobs: - name: Create lib directory if not exists run: mkdir -p ballerina/lib - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master + uses: aquasecurity/trivy-action@0.23.0 with: scan-type: 'rootfs' scan-ref: '/github/workspace/ballerina/lib' diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index 3e3b3389d3..7258d43e39 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -24,7 +24,7 @@ jobs: - name: Create lib directory if not exists run: mkdir -p ballerina/lib - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@master + uses: aquasecurity/trivy-action@0.23.0 with: scan-type: 'rootfs' scan-ref: '/github/workspace/ballerina/lib' diff --git a/.trivyignore b/.trivyignore index 2738392882..eadd990ef6 100644 --- a/.trivyignore +++ b/.trivyignore @@ -2,3 +2,4 @@ CVE-2024-34447 CVE-2024-29857 CVE-2024-30171 CVE-2024-30172 +CVE-2024-7254 diff --git a/ballerina-tests/build.gradle b/ballerina-tests/build.gradle index d75a062b1e..e8809cd3cc 100644 --- a/ballerina-tests/build.gradle +++ b/ballerina-tests/build.gradle @@ -244,7 +244,7 @@ task startLdapServer() { if (!stdOut.toString().contains("openldap-server")) { println "Starting LDAP server." exec { - commandLine 'sh', '-c', "docker-compose -f $project.projectDir/resources/openldap/docker-compose.yml up -d" + commandLine 'sh', '-c', "docker compose -f $project.projectDir/resources/openldap/compose.yml up -d" standardOutput = stdOut } println stdOut.toString() diff --git a/ballerina-tests/http-advanced-tests/Ballerina.toml b/ballerina-tests/http-advanced-tests/Ballerina.toml index a7c5f8f4d5..8b7f453d76 100644 --- a/ballerina-tests/http-advanced-tests/Ballerina.toml +++ b/ballerina-tests/http-advanced-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_advanced_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-advanced-tests/Dependencies.toml b/ballerina-tests/http-advanced-tests/Dependencies.toml index 2316ae21b2..16139137af 100644 --- a/ballerina-tests/http-advanced-tests/Dependencies.toml +++ b/ballerina-tests/http-advanced-tests/Dependencies.toml @@ -73,7 +73,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -105,7 +105,7 @@ modules = [ [[package]] org = "ballerina" name = "http_advanced_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "file"}, @@ -125,7 +125,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-client-tests/Ballerina.toml b/ballerina-tests/http-client-tests/Ballerina.toml index 71c912aa45..13df10c791 100644 --- a/ballerina-tests/http-client-tests/Ballerina.toml +++ b/ballerina-tests/http-client-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_client_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-client-tests/Dependencies.toml b/ballerina-tests/http-client-tests/Dependencies.toml index 301e1f2895..1c9014fec3 100644 --- a/ballerina-tests/http-client-tests/Dependencies.toml +++ b/ballerina-tests/http-client-tests/Dependencies.toml @@ -70,7 +70,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "http_client_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "http"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-dispatching-tests/Ballerina.toml b/ballerina-tests/http-dispatching-tests/Ballerina.toml index f3000885bb..85211b034e 100644 --- a/ballerina-tests/http-dispatching-tests/Ballerina.toml +++ b/ballerina-tests/http-dispatching-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_dispatching_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-dispatching-tests/Dependencies.toml b/ballerina-tests/http-dispatching-tests/Dependencies.toml index 70328cc437..5717f4cda7 100644 --- a/ballerina-tests/http-dispatching-tests/Dependencies.toml +++ b/ballerina-tests/http-dispatching-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_dispatching_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -120,7 +120,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-interceptor-tests/Ballerina.toml b/ballerina-tests/http-interceptor-tests/Ballerina.toml index abf3e73059..a66fe84f9b 100644 --- a/ballerina-tests/http-interceptor-tests/Ballerina.toml +++ b/ballerina-tests/http-interceptor-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_interceptor_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-interceptor-tests/Dependencies.toml b/ballerina-tests/http-interceptor-tests/Dependencies.toml index f5acd12594..3cc4d564d1 100644 --- a/ballerina-tests/http-interceptor-tests/Dependencies.toml +++ b/ballerina-tests/http-interceptor-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_interceptor_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -115,7 +115,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-misc-tests/Ballerina.toml b/ballerina-tests/http-misc-tests/Ballerina.toml index 3fdc9e4a98..f6f78a9aca 100644 --- a/ballerina-tests/http-misc-tests/Ballerina.toml +++ b/ballerina-tests/http-misc-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_misc_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-misc-tests/Dependencies.toml b/ballerina-tests/http-misc-tests/Dependencies.toml index 4cf0c8e24e..4c4f2b1df9 100644 --- a/ballerina-tests/http-misc-tests/Dependencies.toml +++ b/ballerina-tests/http-misc-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_misc_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -118,7 +118,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-misc-tests/tests/http_header_test.bal b/ballerina-tests/http-misc-tests/tests/http_header_test.bal index 308cd7b93a..31c5e1c1a1 100644 --- a/ballerina-tests/http-misc-tests/tests/http_header_test.bal +++ b/ballerina-tests/http-misc-tests/tests/http_header_test.bal @@ -14,6 +14,7 @@ // specific language governing permissions and limitations // under the License. +import ballerina/mime; import ballerina/test; import ballerina/http; import ballerina/http_test_common as common; @@ -276,3 +277,24 @@ function testPassthruWithBody() returns error? { } } +@test:Config {} +function testAddHeaderWithContentType() returns error? { + http:Request req = new; + check req.setContentType(mime:APPLICATION_JSON); + test:assertEquals(check req.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_JSON]); + req.addHeader(http:CONTENT_TYPE, mime:APPLICATION_XML); + test:assertEquals(check req.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_XML]); + + http:Response res = new; + check res.setContentType(mime:APPLICATION_JSON); + test:assertEquals(check res.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_JSON]); + res.addHeader(http:CONTENT_TYPE, mime:APPLICATION_XML); + test:assertEquals(check res.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_XML]); + + http:PushPromise pushPromise = new; + pushPromise.addHeader(http:CONTENT_TYPE, mime:APPLICATION_JSON); + test:assertEquals(pushPromise.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_JSON]); + pushPromise.addHeader(http:CONTENT_TYPE, mime:APPLICATION_XML); + test:assertEquals(pushPromise.getHeaders(http:CONTENT_TYPE), [mime:APPLICATION_XML]); +} + diff --git a/ballerina-tests/http-resiliency-tests/Ballerina.toml b/ballerina-tests/http-resiliency-tests/Ballerina.toml index 36ed22faa3..4997843d0d 100644 --- a/ballerina-tests/http-resiliency-tests/Ballerina.toml +++ b/ballerina-tests/http-resiliency-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_resiliency_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-resiliency-tests/Dependencies.toml b/ballerina-tests/http-resiliency-tests/Dependencies.toml index 751080ceaa..9f2291536e 100644 --- a/ballerina-tests/http-resiliency-tests/Dependencies.toml +++ b/ballerina-tests/http-resiliency-tests/Dependencies.toml @@ -67,7 +67,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -99,7 +99,7 @@ modules = [ [[package]] org = "ballerina" name = "http_resiliency_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "http"}, {org = "ballerina", name = "http_test_common"}, @@ -116,7 +116,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-security-tests/Ballerina.toml b/ballerina-tests/http-security-tests/Ballerina.toml index 40cfe94cf7..9c8bf50948 100644 --- a/ballerina-tests/http-security-tests/Ballerina.toml +++ b/ballerina-tests/http-security-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_security_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-security-tests/Dependencies.toml b/ballerina-tests/http-security-tests/Dependencies.toml index ae0136b7c1..98a4e56935 100644 --- a/ballerina-tests/http-security-tests/Dependencies.toml +++ b/ballerina-tests/http-security-tests/Dependencies.toml @@ -70,7 +70,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "http_security_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "http"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-service-tests/Ballerina.toml b/ballerina-tests/http-service-tests/Ballerina.toml index cddf3f178b..7eb13ca032 100644 --- a/ballerina-tests/http-service-tests/Ballerina.toml +++ b/ballerina-tests/http-service-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http_service_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http-service-tests/Dependencies.toml b/ballerina-tests/http-service-tests/Dependencies.toml index baabb6989a..7e504e7a0c 100644 --- a/ballerina-tests/http-service-tests/Dependencies.toml +++ b/ballerina-tests/http-service-tests/Dependencies.toml @@ -70,7 +70,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "http_service_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "file"}, {org = "ballerina", name = "http"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/http-test-common/Ballerina.toml b/ballerina-tests/http-test-common/Ballerina.toml index 7e2c202651..ab8aabdf3e 100644 --- a/ballerina-tests/http-test-common/Ballerina.toml +++ b/ballerina-tests/http-test-common/Ballerina.toml @@ -1,4 +1,4 @@ [package] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" diff --git a/ballerina-tests/http-test-common/Dependencies.toml b/ballerina-tests/http-test-common/Dependencies.toml index 0b228cfb5f..c2b2ac93e1 100644 --- a/ballerina-tests/http-test-common/Dependencies.toml +++ b/ballerina-tests/http-test-common/Dependencies.toml @@ -10,7 +10,7 @@ distribution-version = "2201.5.0" [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "lang.string"}, {org = "ballerina", name = "mime"}, diff --git a/ballerina-tests/http2-tests/Ballerina.toml b/ballerina-tests/http2-tests/Ballerina.toml index c445e7eb53..880443707b 100644 --- a/ballerina-tests/http2-tests/Ballerina.toml +++ b/ballerina-tests/http2-tests/Ballerina.toml @@ -1,14 +1,14 @@ [package] org = "ballerina" name = "http2_tests" -version = "2.7.7" +version = "2.7.8" [[dependency]] org = "ballerina" name = "http_test_common" repository = "local" -version = "2.7.7" +version = "2.7.8" [[platform.java11.dependency]] scope = "testOnly" -path = "../../test-utils/build/libs/http-test-utils-2.7.7.jar" +path = "../../test-utils/build/libs/http-test-utils-2.7.8-SNAPSHOT.jar" diff --git a/ballerina-tests/http2-tests/Dependencies.toml b/ballerina-tests/http2-tests/Dependencies.toml index 88f72b7985..796de1c8fc 100644 --- a/ballerina-tests/http2-tests/Dependencies.toml +++ b/ballerina-tests/http2-tests/Dependencies.toml @@ -70,7 +70,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "auth"}, @@ -102,7 +102,7 @@ modules = [ [[package]] org = "ballerina" name = "http2_tests" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "file"}, {org = "ballerina", name = "http"}, @@ -121,7 +121,7 @@ modules = [ [[package]] org = "ballerina" name = "http_test_common" -version = "2.7.7" +version = "2.7.8" scope = "testOnly" dependencies = [ {org = "ballerina", name = "lang.string"}, diff --git a/ballerina-tests/resources/openldap/docker-compose.yml b/ballerina-tests/resources/openldap/compose.yml similarity index 97% rename from ballerina-tests/resources/openldap/docker-compose.yml rename to ballerina-tests/resources/openldap/compose.yml index 63d25ce840..23599088b2 100644 --- a/ballerina-tests/resources/openldap/docker-compose.yml +++ b/ballerina-tests/resources/openldap/compose.yml @@ -1,4 +1,3 @@ -version: '3.7' services: ldap_server: image: osixia/openldap:1.3.0 diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index b05a5a0da4..eee5987756 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" authors = ["Ballerina"] keywords = ["http", "network", "service", "listener", "client"] repository = "https://github.com/ballerina-platform/module-ballerina-http" @@ -12,8 +12,8 @@ distribution = "2201.5.0" [[platform.java11.dependency]] groupId = "io.ballerina.stdlib" artifactId = "http-native" -version = "2.7.7" -path = "../native/build/libs/http-native-2.7.7.jar" +version = "2.7.8" +path = "../native/build/libs/http-native-2.7.8-SNAPSHOT.jar" [[platform.java11.dependency]] groupId = "io.ballerina.stdlib" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index dfb4ff467c..d7fb0e4e1d 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "http-compiler-plugin" class = "io.ballerina.stdlib.http.compiler.HttpCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/http-compiler-plugin-2.7.7.jar" +path = "../compiler-plugin/build/libs/http-compiler-plugin-2.7.8-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index af294dedd5..a558f3c59f 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -51,7 +51,7 @@ modules = [ [[package]] org = "ballerina" name = "crypto" -version = "2.3.0" +version = "2.3.2" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -63,13 +63,11 @@ modules = [ [[package]] org = "ballerina" name = "file" -version = "1.7.0" +version = "1.7.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, - {org = "ballerina", name = "log"}, {org = "ballerina", name = "os"}, - {org = "ballerina", name = "regex"}, {org = "ballerina", name = "time"} ] modules = [ @@ -79,7 +77,7 @@ modules = [ [[package]] org = "ballerina" name = "http" -version = "2.7.7" +version = "2.7.8" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -110,7 +108,7 @@ modules = [ [[package]] org = "ballerina" name = "io" -version = "1.4.0" +version = "1.4.1" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} @@ -240,7 +238,7 @@ modules = [ [[package]] org = "ballerina" name = "log" -version = "2.7.0" +version = "2.7.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -254,7 +252,7 @@ modules = [ [[package]] org = "ballerina" name = "mime" -version = "2.7.0" +version = "2.7.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -304,7 +302,7 @@ dependencies = [ [[package]] org = "ballerina" name = "regex" -version = "1.4.0" +version = "1.4.3" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.string"} @@ -316,7 +314,7 @@ modules = [ [[package]] org = "ballerina" name = "task" -version = "2.3.1" +version = "2.3.2" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "time"} @@ -325,7 +323,7 @@ dependencies = [ [[package]] org = "ballerina" name = "time" -version = "2.2.4" +version = "2.2.5" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] @@ -336,7 +334,7 @@ modules = [ [[package]] org = "ballerina" name = "url" -version = "2.2.3" +version = "2.2.4" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] diff --git a/ballerina/http2_push_promise.bal b/ballerina/http2_push_promise.bal index 1c0540faf4..795d441b03 100644 --- a/ballerina/http2_push_promise.bal +++ b/ballerina/http2_push_promise.bal @@ -59,11 +59,15 @@ public class PushPromise { return externPromiseGetHeaders(self, headerName); } - # Adds the specified key/value pair as an HTTP header to the `http:PushPromise`. + # Adds the specified key/value pair as an HTTP header to the `http:PushPromise`. In the case of the `Content-Type` + # header, the existing value is replaced with the specified value. # # + headerName - The header name # + headerValue - The header value public isolated function addHeader(string headerName, string headerValue) { + if headerName.equalsIgnoreCaseAscii(CONTENT_TYPE) { + return externPromiseSetHeader(self, headerName, headerValue); + } return externPromiseAddHeader(self, headerName, headerValue); } diff --git a/ballerina/http_request.bal b/ballerina/http_request.bal index 133efab91a..39f484df3a 100644 --- a/ballerina/http_request.bal +++ b/ballerina/http_request.bal @@ -165,12 +165,17 @@ public class Request { externRequestSetHeader(self, headerName, headerValue); } - # Adds the specified header to the request. Existing header values are not replaced. Panic if an illegal header is passed. + # Adds the specified header to the request. Existing header values are not replaced, except for the `Content-Type` + # header. In the case of the `Content-Type` header, the existing value is replaced with the specified value. + # Panic if an illegal header is passed. # # + headerName - The header name # + headerValue - The header value public isolated function addHeader(string headerName, string headerValue) { - externRequestAddHeader(self, headerName, headerValue); + if headerName.equalsIgnoreCaseAscii(CONTENT_TYPE) { + return externRequestSetHeader(self, headerName, headerValue); + } + return externRequestAddHeader(self, headerName, headerValue); } # Removes the specified header from the request. diff --git a/ballerina/http_response.bal b/ballerina/http_response.bal index 307f3d9a82..348bcee566 100644 --- a/ballerina/http_response.bal +++ b/ballerina/http_response.bal @@ -109,13 +109,18 @@ public class Response { return externResponseGetHeader(self, headerName, position); } - # Adds the specified header to the response. Existing header values are not replaced. Panic if an illegal header is passed. + # Adds the specified header to the response. Existing header values are not replaced, except for the `Content-Type` + # header. In the case of the `Content-Type` header, the existing value is replaced with the specified value. + #. Panic if an illegal header is passed. # # + headerName - The header name # + headerValue - The header value # + position - Represents the position of the header as an optional parameter. If the position is `http:TRAILING`, # the entity-body of the `Response` must be accessed initially. public isolated function addHeader(string headerName, string headerValue, HeaderPosition position = LEADING) { + if headerName.equalsIgnoreCaseAscii(CONTENT_TYPE) { + return externResponseSetHeader(self, headerName, headerValue, position); + } return externResponseAddHeader(self, headerName, headerValue, position); } diff --git a/changelog.md b/changelog.md index 5cfbd93ad2..90f5243d27 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,12 @@ This file contains all the notable changes done to the Ballerina HTTP package th The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- [Fix duplicating `Content-Type` header via the `addHeader` method](https://github.com/ballerina-platform/ballerina-library/issues/7268) + ## [2.7.7] - 2024-05-29 ### Fixed