🧚 A practical web framework for Gleam

Handle charst

+24 -5
+4 -4
.github/workflows/ci.yml
··· 10 10 test-action: 11 11 runs-on: ubuntu-latest 12 12 steps: 13 - - uses: actions/checkout@v3.5.1 14 - - uses: erlef/setup-beam@v1.15.4 13 + - uses: actions/checkout@v3 14 + - uses: erlef/setup-beam@v1 15 15 with: 16 - otp-version: "25.2" 17 - gleam-version: "0.30.5" 16 + otp-version: "26.0" 17 + gleam-version: "0.31.0" 18 18 rebar3-version: "3" 19 19 # elixir-version: "1.14.2" 20 20 - run: gleam format --check src test
+5
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 + ## Unreleased 4 + 5 + - The `wisp.require_form` now handles `application/x-www-form-urlencoded` 6 + content types with a charset. 7 + 3 8 ## v0.5.0 - 2023-09-13 4 9 5 10 - The `wisp` module gains the `set_cookie`, `get_cookie`, `json_response` and
+2 -1
src/wisp.gleam
··· 911 911 next: fn(FormData) -> Response, 912 912 ) -> Response { 913 913 case list.key_find(request.headers, "content-type") { 914 - Ok("application/x-www-form-urlencoded") -> 914 + Ok("application/x-www-form-urlencoded") 915 + | Ok("application/x-www-form-urlencoded;" <> _) -> 915 916 require_urlencoded_form(request, next) 916 917 917 918 Ok("multipart/form-data; boundary=" <> boundary) ->
+13
test/wisp_test.gleam
··· 532 532 |> should.equal(wisp.ok()) 533 533 } 534 534 535 + pub fn urlencoded_form_with_charset_test() { 536 + testing.post("/", [], "one=1&two=2") 537 + |> request.set_header( 538 + "content-type", 539 + "application/x-www-form-urlencoded; charset=UTF-8", 540 + ) 541 + |> form_handler(fn(form) { 542 + form 543 + |> should.equal(wisp.FormData([#("one", "1"), #("two", "2")], [])) 544 + }) 545 + |> should.equal(wisp.ok()) 546 + } 547 + 535 548 pub fn urlencoded_too_big_form_test() { 536 549 testing.post("/", [], "12") 537 550 |> request.set_header("content-type", "application/x-www-form-urlencoded")