Current section

34 Versions

Jump to

Compare versions

10 files changed
+77 additions
-56 deletions
  @@ -33,12 +33,12 @@ In the example above the Elli Erlang web server is used to run the Gleam HTTP
33 33 service. Here's a full list of the server adapters available, sorted
34 34 alphabetically.
35 35
36 - | Adapter | About |
37 - | --- | --- |
38 - | [Mist][mist] | [Mist][mist] is a high performance pure Gleam web server |
39 - | [gleam_cowboy][cowboy-adapter] | [Cowboy][cowboy] is an Erlang HTTP2 & HTTP1.1 web server |
40 - | [gleam_elli][elli-adapter] | [Elli][elli] is an Erlang HTTP1.1 web server |
41 - | [gleam_plug][plug-adapter] | [Plug][plug] is an Elixir web application interface |
36 + | Adapter | About |
37 + | --- | --- |
38 + | [Mist][mist] | [Mist][mist] is a high performance pure Gleam HTTP 1.1 server |
39 + | [gleam_cowboy][cowboy-adapter] | [Cowboy][cowboy] is an Erlang HTTP2 & HTTP1.1 web server |
40 + | [gleam_elli][elli-adapter] | [Elli][elli] is an Erlang HTTP1.1 web server |
41 + | [gleam_plug][plug-adapter] | [Plug][plug] is an Elixir web application interface |
42 42
43 43 [cowboy]:https://github.com/ninenines/cowboy
44 44 [cowboy-adapter]: https://github.com/gleam-lang/cowboy
  @@ -1,5 +1,5 @@
1 1 name = "gleam_http"
2 - version = "3.5.2"
2 + version = "3.5.3"
3 3 licences = ["Apache-2.0"]
4 4 description = "Types and functions for Gleam HTTP clients and servers"
5 5 gleam = ">= 0.32.0"
  @@ -1,6 +1,6 @@
1 1 {<<"name">>, <<"gleam_http">>}.
2 2 {<<"app">>, <<"gleam_http">>}.
3 - {<<"version">>, <<"3.5.2">>}.
3 + {<<"version">>, <<"3.5.3">>}.
4 4 {<<"description">>, <<"Types and functions for Gleam HTTP clients and servers">>}.
5 5 {<<"licenses">>, [<<"Apache-2.0">>]}.
6 6 {<<"build_tools">>, [<<"gleam">>]}.
  @@ -252,6 +252,8 @@ fn parse_body_loop(
252 252 <<char, data:bytes>> -> {
253 253 parse_body_loop(data, boundary, <<body:bits, char>>)
254 254 }
255 +
256 + _ -> panic as "unreachable"
255 257 }
256 258 }
257 259
  @@ -268,7 +270,8 @@ fn parse_headers_after_prelude(
268 270 // compiler support this.
269 271
270 272 use <- bool.guard(
271 - when: dsize < required_size,
273 + when: dsize
274 + < required_size,
272 275 return: more_please_headers(parse_headers_after_prelude(_, boundary), data),
273 276 )
274 277
  @@ -326,6 +329,8 @@ fn skip_preamble(
326 329 }
327 330
328 331 <<_, data:bytes>> -> skip_preamble(data, boundary)
332 +
333 + _ -> panic as "unreachable"
329 334 }
330 335 }
331 336
  @@ -368,7 +373,7 @@ fn parse_header_name(
368 373 <<char, data:bytes>> ->
369 374 parse_header_name(data, headers, <<name:bits, char>>)
370 375
371 - <<>> -> more_please_headers(parse_header_name(_, headers, name), data)
376 + _ -> more_please_headers(parse_header_name(_, headers, name), data)
372 377 }
373 378 }
374 379
  @@ -423,10 +428,12 @@ fn more_please_headers(
423 428 continuation: fn(BitArray) -> Result(MultipartHeaders, Nil),
424 429 existing: BitArray,
425 430 ) -> Result(MultipartHeaders, Nil) {
426 - Ok(MoreRequiredForHeaders(fn(more) {
427 - use <- bool.guard(more == <<>>, return: Error(Nil))
428 - continuation(<<existing:bits, more:bits>>)
429 - }))
431 + Ok(
432 + MoreRequiredForHeaders(fn(more) {
433 + use <- bool.guard(more == <<>>, return: Error(Nil))
434 + continuation(<<existing:bits, more:bits>>)
435 + }),
436 + )
430 437 }
431 438
432 439 pub type ContentDisposition {
  @@ -1,5 +1,5 @@
1 1 -module(gleam@http).
2 - -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).
2 + -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
3 3
4 4 -export([parse_method/1, method_to_string/1, scheme_to_string/1, scheme_from_string/1, parse_content_disposition/1, parse_multipart_body/2, method_from_dynamic/1, parse_multipart_headers/2]).
5 5 -export_type([method/0, scheme/0, multipart_headers/0, multipart_body/0, content_disposition/0]).
  @@ -373,7 +373,14 @@ parse_body_loop(Data, Boundary, Body) ->
373 373 end;
374 374
375 375 <<Char, Data@3/binary>> ->
376 - parse_body_loop(Data@3, Boundary, <<Body/bitstring, Char>>)
376 + parse_body_loop(Data@3, Boundary, <<Body/bitstring, Char>>);
377 +
378 + _ ->
379 + erlang:error(#{gleam_error => panic,
380 + message => <<"unreachable"/utf8>>,
381 + module => <<"gleam/http"/utf8>>,
382 + function => <<"parse_body_loop"/utf8>>,
383 + line => 256})
377 384 end.
378 385
379 386 -spec parse_body_with_bit_array(bitstring(), bitstring()) -> {ok,
  @@ -487,7 +494,7 @@ parse_header_name(Data, Headers, Name) ->
487 494 <<Char, Data@2/binary>> ->
488 495 parse_header_name(Data@2, Headers, <<Name/bitstring, Char>>);
489 496
490 - <<>> ->
497 + _ ->
491 498 more_please_headers(
492 499 fun(_capture) -> parse_header_name(_capture, Headers, Name) end,
493 500 Data
  @@ -607,7 +614,14 @@ skip_preamble(Data, Boundary) ->
607 614 end;
608 615
609 616 <<_, Data@2/binary>> ->
610 - skip_preamble(Data@2, Boundary)
617 + skip_preamble(Data@2, Boundary);
618 +
619 + _ ->
620 + erlang:error(#{gleam_error => panic,
621 + message => <<"unreachable"/utf8>>,
622 + module => <<"gleam/http"/utf8>>,
623 + function => <<"skip_preamble"/utf8>>,
624 + line => 333})
611 625 end.
612 626
613 627 -spec parse_multipart_headers(bitstring(), binary()) -> {ok,
Loading more files…