mirror of
https://github.com/benbusby/farside.git
synced 2025-06-07 18:06:38 +00:00
Set headers for every HTTPoison request
This serves as a workaround for bot blocking via filtron.
This commit is contained in:
parent
1216854196
commit
4a824e449b
2 changed files with 9 additions and 2 deletions
|
@ -8,4 +8,10 @@ config :farside,
|
||||||
fallback_suffix: "-fallback",
|
fallback_suffix: "-fallback",
|
||||||
previous_suffix: "-previous",
|
previous_suffix: "-previous",
|
||||||
services_json: "services.json",
|
services_json: "services.json",
|
||||||
index: "index.eex"
|
index: "index.eex",
|
||||||
|
headers: [
|
||||||
|
{"User-Agent", "Mozilla/5.0 (Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"},
|
||||||
|
{"Accept", "text/html"},
|
||||||
|
{"Accept-Language", "en-US,en;q=0.5"},
|
||||||
|
{"Accept-Encoding", "gzip, deflate, br"}
|
||||||
|
]
|
||||||
|
|
|
@ -3,6 +3,7 @@ defmodule Farside.Instances do
|
||||||
@update_file Application.fetch_env!(:farside, :update_file)
|
@update_file Application.fetch_env!(:farside, :update_file)
|
||||||
@services_json Application.fetch_env!(:farside, :services_json)
|
@services_json Application.fetch_env!(:farside, :services_json)
|
||||||
@service_prefix Application.fetch_env!(:farside, :service_prefix)
|
@service_prefix Application.fetch_env!(:farside, :service_prefix)
|
||||||
|
@headers Application.fetch_env!(:farside, :headers)
|
||||||
|
|
||||||
def sync() do
|
def sync() do
|
||||||
File.rename(@update_file, "#{@update_file}-prev")
|
File.rename(@update_file, "#{@update_file}-prev")
|
||||||
|
@ -21,7 +22,7 @@ defmodule Farside.Instances do
|
||||||
System.get_env("FARSIDE_TEST") ->
|
System.get_env("FARSIDE_TEST") ->
|
||||||
:good
|
:good
|
||||||
true ->
|
true ->
|
||||||
case HTTPoison.get(url) do
|
case HTTPoison.get(url, @headers) do
|
||||||
{:ok, %HTTPoison.Response{status_code: 200}} ->
|
{:ok, %HTTPoison.Response{status_code: 200}} ->
|
||||||
# TODO: Add validation of results, not just status code
|
# TODO: Add validation of results, not just status code
|
||||||
:good
|
:good
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue