Skip to content

Commit

Permalink
Merge branch '1.2.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrudel committed Feb 13, 2024
2 parents b7ce556 + a192316 commit e106117
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
that we never consumed and don't care about
* We no longer explicitly close the connection when we receive a GOAWAY frame

## 1.2.1 (12 Fed 2024)

### Changes

* Disable logging of unknown messages received by an idle HTTP/1 handler to
avoid noise on long polling clients. This can be changed via the
`log_unknown_messages` http_1 option (#299)

## 1.2.0 (31 Jan 2024)

### Enhancements
Expand Down
5 changes: 4 additions & 1 deletion lib/bandit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ defmodule Bandit do
Defaults to 50 headers
* `max_requests`: The maximum number of requests to serve in a single
HTTP/1.1 connection before closing the connection. Defaults to 0 (no limit)
* `log_unknown_messages`: Whether or not to log unknown messages sent to the handler process.
Defaults to `false`
* `compress`: Whether or not to attempt compression of responses via content-encoding
negotiation as described in
[RFC9110§8.4](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.4). Defaults to true
Expand All @@ -106,6 +108,7 @@ defmodule Bandit do
max_header_length: pos_integer(),
max_header_count: pos_integer(),
max_requests: pos_integer(),
log_unknown_messages: boolean(),
compress: boolean(),
deflate_opions: deflate_options()
]
Expand Down Expand Up @@ -183,7 +186,7 @@ defmodule Bandit do
end

@top_level_keys ~w(plug scheme port ip keyfile certfile otp_app cipher_suite display_plug startup_log thousand_island_options http_1_options http_2_options websocket_options)a
@http_1_keys ~w(enabled max_request_line_length max_header_length max_header_count max_requests compress deflate_options)a
@http_1_keys ~w(enabled max_request_line_length max_header_length max_header_count max_requests log_unknown_messages compress deflate_options)a
@http_2_keys ~w(enabled max_header_block_size max_requests default_local_settings compress deflate_options)a
@websocket_keys ~w(enabled max_frame_size validate_text_frames compress)a
@thousand_island_keys ThousandIsland.ServerConfig.__struct__()
Expand Down
2 changes: 1 addition & 1 deletion lib/bandit/http1/handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ defmodule Bandit.HTTP1.Handler do
do: {:noreply, {socket, state}, socket.read_timeout}

def handle_info(msg, {socket, state}) do
log_no_handle_info(msg)
if Keyword.get(state.opts.http_1, :log_unknown_messages, false), do: log_no_handle_info(msg)
{:noreply, {socket, state}, socket.read_timeout}
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Bandit.MixProject do
def project do
[
app: :bandit,
version: "1.2.0",
version: "1.2.1",
elixir: "~> 1.13",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
4 changes: 3 additions & 1 deletion test/bandit/http1/request_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1453,9 +1453,11 @@ defmodule HTTP1RequestTest do

test "does not do anything special with EXIT messages from abnormally terminating spwaned processes",
context do
context = http_server(context, http_1_options: [log_unknown_messages: true])

errors =
capture_log(fn ->
Req.get!(context.req, url: "/spawn_abnormal_child")
Req.get!(url: "/spawn_abnormal_child", base_url: context[:base])

# Let the backing process see & handle the handle_info EXIT message
Process.sleep(100)
Expand Down

0 comments on commit e106117

Please sign in to comment.