Visitar URL original
Add `Context.addHeader` method by Copilot · Pull Request #2605 · javalin/javalin · GitHub
Skip to content

Add Context.addHeader method - #2605

Merged
tipsy merged 3 commits into
masterfrom
copilot/support-context-addheader
Jun 7, 2026
Merged

tipsy merged 3 commits into
masterfrom
copilot/support-context-addheader

Conversation

Copilot AI commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Context only exposes header(name, value) (which overwrites) and removeHeader(name). There's no way to append an additional value to an existing response header without dropping down to ctx.res().addHeader(...).

  • Add addHeader(name: String, value: String) to Context, delegating to res().addHeader()
  • Add integration test verifying both values are present after header() + addHeader() on the same key
ctx.header("X-Custom", "value1")
ctx.addHeader("X-Custom", "value2") // response now has both values

Copilot AI linked an issue Jun 7, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add addHeader method to Context for extending headers Add Context.addHeader method Jun 7, 2026
Copilot AI requested a review from tipsy June 7, 2026 09:45
Copilot finished work on behalf of tipsy June 7, 2026 09:45
@tipsy

tipsy commented Jun 7, 2026

Copy link
Copy Markdown
Member

@copilot add another test to prove the difference between the methods? Also, can you be more succinct in your tests?

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add another test to prove the difference between the methods? Also, can you be more succinct in your tests?

Done in the latest commit. Replaced the single test with two succinct ones:

  • adding a header appends values — two addHeader calls, both values present
  • setting a header overwrites previous values — addHeader then header, only the last value remains

Copilot finished work on behalf of tipsy June 7, 2026 09:56
@tipsy
tipsy marked this pull request as ready for review June 7, 2026 10:07
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.46%. Comparing base (4b82867) to head (4ca37e1).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2605   +/-   ##
=========================================
  Coverage     86.46%   86.46%           
- Complexity     1555     1556    +1     
=========================================
  Files           157      157           
  Lines          4448     4449    +1     
  Branches        542      542           
=========================================
+ Hits           3846     3847    +1     
  Misses          370      370           
  Partials        232      232           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tipsy tipsy mentioned this pull request Jun 7, 2026
@tipsy
tipsy merged commit fd59a40 into master Jun 7, 2026
16 checks passed
@tipsy
tipsy deleted the copilot/support-context-addheader branch June 7, 2026 16:06
mergify Bot added a commit to robfrank/linklift that referenced this pull request Aug 20, 2026
Bumps `javalin.version` from 7.2.2 to 7.2.3.
Updates `io.javalin:javalin-bundle` from 7.2.2 to 7.2.3
Release notes

*Sourced from [io.javalin:javalin-bundle's releases](https://github.com/javalin/javalin/releases).*

> 7.2.3
> -----
>
> What's Changed
> --------------
>
> * [workflow]: Bump codecov/codecov-action from 6.0.0 to 6.0.1 in the dependencies group by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2597](https://redirect.github.com/javalin/javalin/pull/2597)
> * [deps] Bump grouped dependencies (excluding Jetty) by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2604](https://redirect.github.com/javalin/javalin/pull/2604)
> * Add default enum converters for validation by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2600](https://redirect.github.com/javalin/javalin/pull/2600)
> * Add `Context.addHeader` method by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2605](https://redirect.github.com/javalin/javalin/pull/2605)
> * [workflow]: Bump codecov/codecov-action from 6.0.1 to 7.0.0 in the dependencies group by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2606](https://redirect.github.com/javalin/javalin/pull/2606)
> * [http] Return 404 for unrecognized request methods instead of 500 by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2609](https://redirect.github.com/javalin/javalin/pull/2609)
> * [workflow]: Bump the dependencies group across 1 directory with 2 updates by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2612](https://redirect.github.com/javalin/javalin/pull/2612)
> * Stream static files instead of reading all bytes into memory by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2618](https://redirect.github.com/javalin/javalin/pull/2618)
> * Add application/xml to ContentType by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2619](https://redirect.github.com/javalin/javalin/pull/2619)
> * [deps]: Bump the dependencies group across 1 directory with 32 updates by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2617](https://redirect.github.com/javalin/javalin/pull/2617)
> * [deps] Bump stable deps and sync OptionalDependency.kt by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2624](https://redirect.github.com/javalin/javalin/pull/2624)
>
> **Full Changelog**: <javalin/javalin@javalin-parent-7.2.1...javalin-parent-7.2.3>


Commits

* [`8c12b9f`](javalin/javalin@8c12b9f) [maven-release-plugin] prepare release javalin-parent-7.2.3
* [`3208ac5`](javalin/javalin@3208ac5) [deps] Bump stable deps and sync OptionalDependency.kt ([#2624](https://redirect.github.com/javalin/javalin/issues/2624))
* [`54f0559`](javalin/javalin@54f0559) [deps]: Bump the dependencies group across 1 directory with 32 updates ([#2617](https://redirect.github.com/javalin/javalin/issues/2617))
* [`48bf31c`](javalin/javalin@48bf31c) [content-type] Add application/xml (closes [#2614](https://redirect.github.com/javalin/javalin/issues/2614))
* [`c83b8b2`](javalin/javalin@c83b8b2) [static-files] Stream static files instead of reading into memory ([#2618](https://redirect.github.com/javalin/javalin/issues/2618))
* [`6600d23`](javalin/javalin@6600d23) [workflow]: Bump the dependencies group across 1 directory with 2 updates ([#2](https://redirect.github.com/javalin/javalin/issues/2)...
* [`0ae00ca`](javalin/javalin@0ae00ca) [http] Return 404 for unrecognized request methods instead of 500 ([#2609](https://redirect.github.com/javalin/javalin/issues/2609))
* [`c397adc`](javalin/javalin@c397adc) [workflow]: Bump codecov/codecov-action in the dependencies group ([#2606](https://redirect.github.com/javalin/javalin/issues/2606))
* [`fd59a40`](javalin/javalin@fd59a40) [context] Add `Context.addHeader` method ([#2605](https://redirect.github.com/javalin/javalin/issues/2605))
* [`4b82867`](javalin/javalin@4b82867) [validation] Add default enum converters ([#2600](https://redirect.github.com/javalin/javalin/issues/2600))
* Additional commits viewable in [compare view](javalin/javalin@javalin-parent-7.2.2...javalin-parent-7.2.3)
  
Updates `io.javalin.community.openapi:javalin-openapi-plugin` from 7.2.2 to 7.2.3
Release notes

*Sourced from [io.javalin.community.openapi:javalin-openapi-plugin's releases](https://github.com/javalin/javalin-openapi/releases).*

> 7.2.3
> -----
>
> **Changes**
>
> * Bumped Javalin to 7.2.3
>
> **Sponsors**
> Thanks to everyone who supported me this month 💜
>
> **Minimal requirements**
>
> * Java 17+ / Kotlin 2.3+
> * Javalin 7.2.3


Commits

* [`48b718d`](javalin/javalin-openapi@48b718d) [GH-285](https://redirect.github.com/javalin/javalin-openapi/issues/285) Release 7.2.3
* [`87f7bdf`](javalin/javalin-openapi@87f7bdf) [GH-280](https://redirect.github.com/javalin/javalin-openapi/issues/280) Support `x-enum-descriptions` for enums ([#281](https://redirect.github.com/javalin/javalin-openapi/issues/281))
* See full diff in [compare view](javalin/javalin-openapi@7.2.2...7.2.3)
  
Updates `io.javalin.community.openapi:javalin-swagger-plugin` from 7.2.2 to 7.2.3
Release notes

*Sourced from [io.javalin.community.openapi:javalin-swagger-plugin's releases](https://github.com/javalin/javalin-openapi/releases).*

> 7.2.3
> -----
>
> **Changes**
>
> * Bumped Javalin to 7.2.3
>
> **Sponsors**
> Thanks to everyone who supported me this month 💜
>
> **Minimal requirements**
>
> * Java 17+ / Kotlin 2.3+
> * Javalin 7.2.3


Commits

* [`48b718d`](javalin/javalin-openapi@48b718d) [GH-285](https://redirect.github.com/javalin/javalin-openapi/issues/285) Release 7.2.3
* [`87f7bdf`](javalin/javalin-openapi@87f7bdf) [GH-280](https://redirect.github.com/javalin/javalin-openapi/issues/280) Support `x-enum-descriptions` for enums ([#281](https://redirect.github.com/javalin/javalin-openapi/issues/281))
* See full diff in [compare view](javalin/javalin-openapi@7.2.2...7.2.3)
  
Updates `io.javalin:javalin-micrometer` from 7.2.2 to 7.2.3
Release notes

*Sourced from [io.javalin:javalin-micrometer's releases](https://github.com/javalin/javalin/releases).*

> 7.2.3
> -----
>
> What's Changed
> --------------
>
> * [workflow]: Bump codecov/codecov-action from 6.0.0 to 6.0.1 in the dependencies group by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2597](https://redirect.github.com/javalin/javalin/pull/2597)
> * [deps] Bump grouped dependencies (excluding Jetty) by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2604](https://redirect.github.com/javalin/javalin/pull/2604)
> * Add default enum converters for validation by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2600](https://redirect.github.com/javalin/javalin/pull/2600)
> * Add `Context.addHeader` method by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2605](https://redirect.github.com/javalin/javalin/pull/2605)
> * [workflow]: Bump codecov/codecov-action from 6.0.1 to 7.0.0 in the dependencies group by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2606](https://redirect.github.com/javalin/javalin/pull/2606)
> * [http] Return 404 for unrecognized request methods instead of 500 by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2609](https://redirect.github.com/javalin/javalin/pull/2609)
> * [workflow]: Bump the dependencies group across 1 directory with 2 updates by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2612](https://redirect.github.com/javalin/javalin/pull/2612)
> * Stream static files instead of reading all bytes into memory by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2618](https://redirect.github.com/javalin/javalin/pull/2618)
> * Add application/xml to ContentType by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2619](https://redirect.github.com/javalin/javalin/pull/2619)
> * [deps]: Bump the dependencies group across 1 directory with 32 updates by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2617](https://redirect.github.com/javalin/javalin/pull/2617)
> * [deps] Bump stable deps and sync OptionalDependency.kt by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2624](https://redirect.github.com/javalin/javalin/pull/2624)
>
> **Full Changelog**: <javalin/javalin@javalin-parent-7.2.1...javalin-parent-7.2.3>


Commits

* [`8c12b9f`](javalin/javalin@8c12b9f) [maven-release-plugin] prepare release javalin-parent-7.2.3
* [`3208ac5`](javalin/javalin@3208ac5) [deps] Bump stable deps and sync OptionalDependency.kt ([#2624](https://redirect.github.com/javalin/javalin/issues/2624))
* [`54f0559`](javalin/javalin@54f0559) [deps]: Bump the dependencies group across 1 directory with 32 updates ([#2617](https://redirect.github.com/javalin/javalin/issues/2617))
* [`48bf31c`](javalin/javalin@48bf31c) [content-type] Add application/xml (closes [#2614](https://redirect.github.com/javalin/javalin/issues/2614))
* [`c83b8b2`](javalin/javalin@c83b8b2) [static-files] Stream static files instead of reading into memory ([#2618](https://redirect.github.com/javalin/javalin/issues/2618))
* [`6600d23`](javalin/javalin@6600d23) [workflow]: Bump the dependencies group across 1 directory with 2 updates ([#2](https://redirect.github.com/javalin/javalin/issues/2)...
* [`0ae00ca`](javalin/javalin@0ae00ca) [http] Return 404 for unrecognized request methods instead of 500 ([#2609](https://redirect.github.com/javalin/javalin/issues/2609))
* [`c397adc`](javalin/javalin@c397adc) [workflow]: Bump codecov/codecov-action in the dependencies group ([#2606](https://redirect.github.com/javalin/javalin/issues/2606))
* [`fd59a40`](javalin/javalin@fd59a40) [context] Add `Context.addHeader` method ([#2605](https://redirect.github.com/javalin/javalin/issues/2605))
* [`4b82867`](javalin/javalin@4b82867) [validation] Add default enum converters ([#2600](https://redirect.github.com/javalin/javalin/issues/2600))
* Additional commits viewable in [compare view](javalin/javalin@javalin-parent-7.2.2...javalin-parent-7.2.3)
  
Updates `io.javalin:javalin-testtools` from 7.2.2 to 7.2.3
Release notes

*Sourced from [io.javalin:javalin-testtools's releases](https://github.com/javalin/javalin/releases).*

> 7.2.3
> -----
>
> What's Changed
> --------------
>
> * [workflow]: Bump codecov/codecov-action from 6.0.0 to 6.0.1 in the dependencies group by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2597](https://redirect.github.com/javalin/javalin/pull/2597)
> * [deps] Bump grouped dependencies (excluding Jetty) by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2604](https://redirect.github.com/javalin/javalin/pull/2604)
> * Add default enum converters for validation by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2600](https://redirect.github.com/javalin/javalin/pull/2600)
> * Add `Context.addHeader` method by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2605](https://redirect.github.com/javalin/javalin/pull/2605)
> * [workflow]: Bump codecov/codecov-action from 6.0.1 to 7.0.0 in the dependencies group by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2606](https://redirect.github.com/javalin/javalin/pull/2606)
> * [http] Return 404 for unrecognized request methods instead of 500 by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2609](https://redirect.github.com/javalin/javalin/pull/2609)
> * [workflow]: Bump the dependencies group across 1 directory with 2 updates by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2612](https://redirect.github.com/javalin/javalin/pull/2612)
> * Stream static files instead of reading all bytes into memory by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2618](https://redirect.github.com/javalin/javalin/pull/2618)
> * Add application/xml to ContentType by [`@​tipsy`](https://github.com/tipsy) with [`@​Copilot`](https://github.com/Copilot) in [javalin/javalin#2619](https://redirect.github.com/javalin/javalin/pull/2619)
> * [deps]: Bump the dependencies group across 1 directory with 32 updates by [`@​dependabot`](https://github.com/dependabot)[bot] in [javalin/javalin#2617](https://redirect.github.com/javalin/javalin/pull/2617)
> * [deps] Bump stable deps and sync OptionalDependency.kt by [`@​tipsy`](https://github.com/tipsy) in [javalin/javalin#2624](https://redirect.github.com/javalin/javalin/pull/2624)
>
> **Full Changelog**: <javalin/javalin@javalin-parent-7.2.1...javalin-parent-7.2.3>


Commits

* [`8c12b9f`](javalin/javalin@8c12b9f) [maven-release-plugin] prepare release javalin-parent-7.2.3
* [`3208ac5`](javalin/javalin@3208ac5) [deps] Bump stable deps and sync OptionalDependency.kt ([#2624](https://redirect.github.com/javalin/javalin/issues/2624))
* [`54f0559`](javalin/javalin@54f0559) [deps]: Bump the dependencies group across 1 directory with 32 updates ([#2617](https://redirect.github.com/javalin/javalin/issues/2617))
* [`48bf31c`](javalin/javalin@48bf31c) [content-type] Add application/xml (closes [#2614](https://redirect.github.com/javalin/javalin/issues/2614))
* [`c83b8b2`](javalin/javalin@c83b8b2) [static-files] Stream static files instead of reading into memory ([#2618](https://redirect.github.com/javalin/javalin/issues/2618))
* [`6600d23`](javalin/javalin@6600d23) [workflow]: Bump the dependencies group across 1 directory with 2 updates ([#2](https://redirect.github.com/javalin/javalin/issues/2)...
* [`0ae00ca`](javalin/javalin@0ae00ca) [http] Return 404 for unrecognized request methods instead of 500 ([#2609](https://redirect.github.com/javalin/javalin/issues/2609))
* [`c397adc`](javalin/javalin@c397adc) [workflow]: Bump codecov/codecov-action in the dependencies group ([#2606](https://redirect.github.com/javalin/javalin/issues/2606))
* [`fd59a40`](javalin/javalin@fd59a40) [context] Add `Context.addHeader` method ([#2605](https://redirect.github.com/javalin/javalin/issues/2605))
* [`4b82867`](javalin/javalin@4b82867) [validation] Add default enum converters ([#2600](https://redirect.github.com/javalin/javalin/issues/2600))
* Additional commits viewable in [compare view](javalin/javalin@javalin-parent-7.2.2...javalin-parent-7.2.3)
  
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Context.addHeader

3 participants