This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cowboy returned 431 because it was unable to parse the request headers. This may happen because there are no headers, or there are too many headers or the header name or value are too large (such as a large cookie). You can customize those values when configuring your http/https server. The configuration option and default values are shown below: protocol_options: [ max_header_name_length: 64, max_header_value_length: 4096, max_headers: 100 ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[error] [early_error_time: -576460745611033000, partial_req: %{headers: %{"accept" => "*/*", "host" => "localhost:5000", "user-agent" => "curl/7.64.1"}, method: "GET", path: "/healthcheck", peer: {{127, 0, 0, 1}, 51940}, qs: "", ref: YourAppName.Endpoint.HTTP, version: :"HTTP/1.1"}, pid: #PID<0.718.0>, reason: {:connection_error, :limit_reached, :"A header value is larger than configuration allows. (RFC7230 3.2.5, RFC6585 5)"}, ref: YourAppName.Endpoint.HTTP, resp_headers: %{"connection" => "close", "content-length" => "0"}, resp_status: 431, streamid: 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule YourAppName.LogIncompleteRequestHandler do | |
require Logger | |
def handle_event([:cowboy, :request, :early_error], _response, request, nil) do | |
Logger.error(IO.inspect(request)) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:ok = :telemetry.attach( | |
"cowboy-request-handler", | |
[:cowboy, :request, :early_error], | |
&YourAppName.LogIncompleteRequestHandler.handle_event/4, | |
nil | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Vat do | |
@moduledoc """ | |
Elixir In Action book example for function overloading | |
""" | |
def price(%{country: :germany, price: price}), do: calc_total_price(1.19, price) | |
def price(%{country: :greece, price: price}), do: calc_total_price(1.24, price) | |
def price(%{country: :croatia, price: price}), do: calc_total_price(1.25, price) | |
def price(unknown), do: {:unknown_country_data, unknown} | |
defp calc_total_price(vat, price) when vat > 1.20, do: "Expensive country: " <> "#{vat * price}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<script src="https://bossanova.uk/jspreadsheet/v3/jexcel.js"></script> | |
<link rel="stylesheet" href="https://bossanova.uk/jspreadsheet/v3/jexcel.css" type="text/css" /> | |
<script src="https://jsuites.net/v3/jsuites.js"></script> | |
<link rel="stylesheet" href="https://jsuites.net/v3/jsuites.css" type="text/css" /> | |
<div id='my-spreadsheet'></div> | |
<script> | |
data = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Vat do | |
@moduledoc """ | |
Elixir In Action book example for function overloading | |
""" | |
def price(%{country: :germany, price: price}), do: 1.19 * price | |
def price(%{country: :greece, price: price}), do: 1.24 * price | |
def price(%{country: :croatia, price: price}), do: 1.25 * price | |
def price(unknown), do: {:unknown_country_data, unknown} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Vat do | |
@moduledoc """ | |
Elixir In Action book example for function overloading | |
""" | |
def price(%{country: :germany, price: price}), do: 1.19 * price | |
def price(%{country: :greece, price: price}), do: 1.24 * price | |
def price(%{country: :croatia, price: price}), do: 1.25 * price | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mox.defmock(ExKeyCDN.MockZone, for: ExKeyCDN.ZoneBehaviour) | |
Application.put_env(:exkeycdn, :zone, ExKeyCDN.MockZone) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ExKeyCDN.ZoneTest do | |
use ExUnit.Case, async: true | |
import Mox | |
# Make sure mocks are verified when the test exits | |
setup :verify_on_exit! | |
describe "list/0" do | |
test "mock" do |
NewerOlder