From 37b2c2ce7892487b1c31d6ad3f7988841014ba89 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 4 Aug 2024 11:14:06 +0200 Subject: refactor(users/Profpatsch/whatcd-resolver): continue http MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ideally thereā€™d be a better generic abstraction of doing basic http calls (with tracing) in the future, but for now just reexport. Change-Id: Id7548739ea62e9172f2773f8db79fe726096b7f1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12136 Tested-by: BuildkiteCI Reviewed-by: Profpatsch --- users/Profpatsch/whatcd-resolver/src/Http.hs | 4 ++++ users/Profpatsch/whatcd-resolver/src/JsonLd.hs | 1 - users/Profpatsch/whatcd-resolver/src/Redacted.hs | 8 +++----- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'users/Profpatsch/whatcd-resolver') diff --git a/users/Profpatsch/whatcd-resolver/src/Http.hs b/users/Profpatsch/whatcd-resolver/src/Http.hs index 4376b721e80a..f0f635e7d837 100644 --- a/users/Profpatsch/whatcd-resolver/src/Http.hs +++ b/users/Profpatsch/whatcd-resolver/src/Http.hs @@ -5,11 +5,15 @@ module Http RequestOptions (..), mkRequestOptions, httpJson, + Http.httpBS, + Http.Request, Http.setRequestMethod, + Http.setQueryString, Http.setRequestBodyLBS, Http.setRequestHeader, Http.getResponseStatus, Http.getResponseHeader, + Http.getResponseHeaders, Http.getResponseBody, ) where diff --git a/users/Profpatsch/whatcd-resolver/src/JsonLd.hs b/users/Profpatsch/whatcd-resolver/src/JsonLd.hs index 80d04f8e78a5..db2fb9434554 100644 --- a/users/Profpatsch/whatcd-resolver/src/JsonLd.hs +++ b/users/Profpatsch/whatcd-resolver/src/JsonLd.hs @@ -16,7 +16,6 @@ import IHP.HSX.QQ (hsx) import Json qualified import Label import MyPrelude -import Network.HTTP.Client.Conduit qualified as Http import Network.HTTP.Types.URI qualified as Url import Network.URI (URI) import Optional diff --git a/users/Profpatsch/whatcd-resolver/src/Redacted.hs b/users/Profpatsch/whatcd-resolver/src/Redacted.hs index 0c9506e57e1e..2979b4400a2d 100644 --- a/users/Profpatsch/whatcd-resolver/src/Redacted.hs +++ b/users/Profpatsch/whatcd-resolver/src/Redacted.hs @@ -19,8 +19,6 @@ import Http qualified import Json qualified import Label import MyPrelude -import Network.HTTP.Client.Conduit qualified as Http -import Network.HTTP.Simple qualified as Http import Network.HTTP.Types import Network.Wai.Parse qualified as Wai import OpenTelemetry.Trace qualified as Otel hiding (getTracer, inSpan, inSpan') @@ -503,17 +501,17 @@ httpTorrent span req = >>= assertM span ( \resp -> do - let statusCode = resp & Http.responseStatus & (.statusCode) + let statusCode = resp & Http.getResponseStatus & (.statusCode) contentType = resp - & Http.responseHeaders + & Http.getResponseHeaders & List.lookup "content-type" <&> Wai.parseContentType <&> (\(ct, _mimeAttributes) -> ct) if | statusCode == 200, Just "application/x-bittorrent" <- contentType -> - Right $ (resp & Http.responseBody) + Right $ (resp & Http.getResponseBody) | statusCode == 200, Just otherType <- contentType -> Left [fmt|Redacted returned a non-torrent body, with content-type "{otherType}"|] -- cgit 1.4.1