From 036c4d8de315d639276c7e1204e4f7001a5a7886 Mon Sep 17 00:00:00 2001 From: Gabriel Giordano Date: Thu, 23 Mar 2023 16:37:22 +0100 Subject: [PATCH 1/2] Add Mint client options --- README.md | 7 +++++++ lib/tz/compiler_runner.ex | 3 ++- lib/tz/http/mint/http_client.ex | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5d14ea..aea5130 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,13 @@ defp deps do end ``` +You may also add custom [options](https://hexdocs.pm/mint/Mint.HTTP.html#connect/4-options) for the http client `mint`: + +```elixir +config :tz, Tz.HTTP.Mint.HTTPClient, + proxy: {:http, proxy_host, proxy_port, []} +``` + ## Custom HTTP client You may implement the `Tz.HTTP.HTTPClient` behaviour in order to use another HTTP client. diff --git a/lib/tz/compiler_runner.ex b/lib/tz/compiler_runner.ex index c707828..ede622f 100644 --- a/lib/tz/compiler_runner.ex +++ b/lib/tz/compiler_runner.ex @@ -9,7 +9,8 @@ defmodule Tz.CompilerRunner do :data_dir, :iana_version, :build_dst_periods_until_year, - :reject_periods_before_year + :reject_periods_before_year, + Tz.HTTP.Mint.HTTPClient ] unknown_env_keys = diff --git a/lib/tz/http/mint/http_client.ex b/lib/tz/http/mint/http_client.ex index 9267969..e0dd8b6 100644 --- a/lib/tz/http/mint/http_client.ex +++ b/lib/tz/http/mint/http_client.ex @@ -10,7 +10,9 @@ if Code.ensure_loaded?(Mint.HTTP) do @impl Tz.HTTP.HTTPClient def request(hostname, path) do - {:ok, conn} = HTTP.connect(:https, hostname, 443) + opts = Application.get_env(:tz, Tz.HTTP.Mint.HTTPClient, []) + + {:ok, conn} = HTTP.connect(:https, hostname, 443, opts) {:ok, conn, _} = HTTP.request(conn, "GET", path, [], nil) {:ok, response = %MintHTTPResponse{}} = recv_response(conn) From 4c205508affe7c44e827666e2ba6e7bd08af8858 Mon Sep 17 00:00:00 2001 From: Gabriel Giordano Date: Thu, 23 Mar 2023 16:41:55 +0100 Subject: [PATCH 2/2] Bump version --- CHANGELOG.md | 2 ++ README.md | 6 +++--- mix.exs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed6a040..431112b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 0.25.x +* Add custom options for default Mint HTTP client. * Fix the bug that occurs when the maximum available year in an IANA rule exceeds the limit set by the 'max' rule (happened for Palestine). @@ -20,6 +21,7 @@ `:build_dst_periods_until_year` * Add a mix task to download the IANA time zone data for a given version + ## 0.22.x * Add a mix task to download the IANA time zone data for a given version diff --git a/README.md b/README.md index aea5130..53a24db 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ module can, by default, only operate on datetimes in the UTC time zone. Alternat third-party libraries, such as `tz`, to bring in time zone support and deal with datetimes in other time zones than UTC. The `tz` library relies on the [time zone database](https://data.iana.org/time-zones/tzdb/) maintained by -[IANA](https://www.iana.org). As of version 0.25.0, `tz` uses version **tzdata2023a** of the IANA time zone database. +[IANA](https://www.iana.org). As of version 0.25.1, `tz` uses version **tzdata2023a** of the IANA time zone database. * [Installation and usage](#installation-and-usage) * [Core principles](#core-principles) @@ -32,7 +32,7 @@ Add `tz` for Elixir as a dependency in your `mix.exs` file: ```elixir def deps do [ - {:tz, "~> 0.25.0"} + {:tz, "~> 0.25.1"} ] end ``` @@ -173,7 +173,7 @@ defp deps do [ {:castore, "~> 0.1"}, {:mint, "~> 1.4"}, - {:tz, "~> 0.25.0"} + {:tz, "~> 0.25.1"} ] end ``` diff --git a/mix.exs b/mix.exs index dbce237..7086144 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Tz.MixProject do use Mix.Project - @version "0.25.0" + @version "0.25.1" def project do [