Skip to content

Commit

Permalink
enclosing IPv6 literal authority with square brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Aug 27, 2024
1 parent c55b9e5 commit 703df1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Network/HTTP2/Client/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ module Network.HTTP2.Client.Run where
import Control.Concurrent.STM (check)
import qualified Data.ByteString.UTF8 as UTF8
import Data.IORef
import Data.IP (IPv6)
import Network.Control (RxFlow (..), defaultMaxData)
import Network.HTTP.Semantics.Client
import Network.HTTP.Semantics.Client.Internal
import Network.HTTP.Semantics.IO
import Network.Socket (SockAddr)
import Text.Read (readMaybe)
import UnliftIO.Async
import UnliftIO.Concurrent
import UnliftIO.Exception
Expand Down Expand Up @@ -176,12 +178,16 @@ sendRequest conf ctx@Context{..} scheme auth (Request req) = do
-- the ordering of responses can be out-of-order.
-- But for clients, the ordering must be maintained.
-- To implement this, 'outputQStreamID' is used.
let isIPv6 = isJust (readMaybe auth :: Maybe IPv6)
auth'
| isIPv6 = "[" <> UTF8.fromString auth <> "]"
| otherwise = UTF8.fromString auth
let hdr1, hdr2 :: [Header]
hdr1
| scheme /= "" = (":scheme", scheme) : hdr0
| otherwise = hdr0
hdr2
| auth /= "" = (":authority", UTF8.fromString auth) : hdr1
| auth /= "" = (":authority", auth') : hdr1
| otherwise = hdr1
req' = req{outObjHeaders = hdr2}
-- FLOW CONTROL: SETTINGS_MAX_CONCURRENT_STREAMS: send: respecting peer's limit
Expand Down
1 change: 1 addition & 0 deletions http2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ library
containers >=0.6,
http-semantics >= 0.2 && <0.3,
http-types >=0.12 && <0.13,
iproute >= 1.7 && < 1.8,
network >=3.1,
network-byte-order >=0.1.7 && <0.2,
network-control >=0.1 && <0.2,
Expand Down

0 comments on commit 703df1e

Please sign in to comment.