Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions warp/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# ChangeLog for warp

## 3.4.9

* New flag `include-warp-version` can be disabled to remove dependency on `Paths_warp`.
[#1044](https://github.com/yesodweb/wai/pull/1044)

## 3.4.8

* Label the internal hack thread on Windows used to make socket
Expand Down
1 change: 0 additions & 1 deletion warp/Network/Wai/Handler/Warp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ import Network.Wai.Handler.Warp.HTTP2.Request (
import Network.Wai.Handler.Warp.HTTP2.Types
import Network.Wai.Handler.Warp.Imports
import Network.Wai.Handler.Warp.Request
import Network.Wai.Handler.Warp.Response (warpVersion)
import Network.Wai.Handler.Warp.Run
import Network.Wai.Handler.Warp.Settings
import Network.Wai.Handler.Warp.Types hiding (getFileInfo)
Expand Down
1 change: 1 addition & 0 deletions warp/Network/Wai/Handler/Warp/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,4 @@ import Network.Wai.Handler.Warp.SendFile
import Network.Wai.Handler.Warp.Settings
import Network.Wai.Handler.Warp.Types
import Network.Wai.Handler.Warp.Windows

7 changes: 1 addition & 6 deletions warp/Network/Wai/Handler/Warp/Response.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
module Network.Wai.Handler.Warp.Response (
sendResponse,
sanitizeHeaderValue, -- for testing
-- Provided here for backwards compatibility.
warpVersion,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for the maintainers: should we deprecate this and remove it in a future version?

{-# DEPRECATED warpVersion "some message" #-}
warpVersion = Network.Wai.Handler.Warp.Settings.warpVersion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like it's worth it, but thanks for the suggestion 👍

hasBody,
replaceHeader,
Expand All @@ -31,13 +32,11 @@ import Data.Streaming.ByteString.Builder (
newByteStringBuilderRecv,
reuseBufferStrategy,
)
import Data.Version (showVersion)
import Data.Word8 (_cr, _lf, _space, _tab)
import qualified Network.HTTP.Types as H
import qualified Network.HTTP.Types.Header as H
import Network.Wai
import Network.Wai.Internal
import qualified Paths_warp
import qualified System.TimeManager as T

import Network.Wai.Handler.Warp.Buffer (toBuilderBuffer)
Expand Down Expand Up @@ -479,10 +478,6 @@ addDate getdate rspidxhdr hdrs = case rspidxhdr ! fromEnum ResDate of

----------------------------------------------------------------

-- | The version of Warp.
warpVersion :: String
warpVersion = showVersion Paths_warp.version

{-# INLINE addServer #-}
addServer
:: HeaderValue -> IndexedHeader -> H.ResponseHeaders -> H.ResponseHeaders
Expand Down
18 changes: 15 additions & 3 deletions warp/Network/Wai/Handler/Warp/Settings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ import qualified Data.ByteString.Char8 as C8
import Data.Streaming.Network (HostPreference)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import Data.Version (showVersion)
import GHC.IO (IO (IO), unsafeUnmask)
import GHC.IO.Exception (IOErrorType (..))
import GHC.Prim (fork#)
import qualified Network.HTTP.Types as H
import Network.Socket (SockAddr, Socket, accept)
import Network.Wai
import qualified Paths_warp
import System.IO (stderr)
import System.IO.Error (ioeGetErrorType)
import System.TimeManager
Expand All @@ -33,6 +31,11 @@ import Network.Wai.Handler.Warp.Types
import Network.Wai.Handler.Warp.Windows (windowsThreadBlockHack)
#endif

#ifdef INCLUDE_WARP_VERSION
import Data.Version (showVersion)
import qualified Paths_warp
#endif

-- | Various Warp server settings. This is purposely kept as an abstract data
-- type so that new settings can be added without breaking backwards
-- compatibility. In order to create a 'Settings' value, use 'defaultSettings'
Expand Down Expand Up @@ -206,7 +209,7 @@ defaultSettings =
, settingsAccept = defaultAccept
, settingsNoParsePath = False
, settingsInstallShutdownHandler = const $ return ()
, settingsServerName = C8.pack $ "Warp/" ++ showVersion Paths_warp.version
, settingsServerName = C8.pack $ "Warp/" ++ warpVersion
, settingsMaximumBodyFlush = Just 8192
, settingsProxyProtocol = ProxyProtocolNone
, settingsSlowlorisSize = 2048
Expand Down Expand Up @@ -318,3 +321,12 @@ defaultAccept =
#else
accept
#endif

-- | The version of Warp.
warpVersion :: String
warpVersion =
#ifdef INCLUDE_WARP_VERSION
showVersion Paths_warp.version
#else
"unknown"
#endif
27 changes: 23 additions & 4 deletions warp/warp.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: >=1.10
name: warp
version: 3.4.8
version: 3.4.9
license: MIT
license-file: LICENSE
maintainer: michael@snoyman.com
Expand Down Expand Up @@ -34,6 +34,16 @@ flag network-bytestring
flag allow-sendfilefd
description: Allow use of sendfileFd (not available on GNU/kFreeBSD)

flag include-warp-version
description:
Exposes the version in Network.Wai.Handler.Warp.warpVersion.
This adds a dependency on Paths_warp so application binaries may
reference subpaths of GHC. For nix users this may result in binaries
with a large transitive runtime dependency closure that includes GHC
itself.
default: True
manual: True

flag warp-debug
description: print debug output. not suitable for production
default: False
Expand Down Expand Up @@ -78,7 +88,9 @@ library
Network.Wai.Handler.Warp.Types
Network.Wai.Handler.Warp.Windows
Network.Wai.Handler.Warp.WithApplication
Paths_warp

if flag(include-warp-version)
other-modules: Paths_warp

default-language: Haskell2010
ghc-options: -Wall
Expand Down Expand Up @@ -140,6 +152,9 @@ library
if impl(ghc >=8)
default-extensions: Strict StrictData

if flag(include-warp-version)
cpp-options: -DINCLUDE_WARP_VERSION

test-suite doctest
type: exitcode-stdio-1.0
main-is: doctests.hs
Expand Down Expand Up @@ -208,7 +223,9 @@ test-suite spec
Network.Wai.Handler.Warp.Types
Network.Wai.Handler.Warp.Windows
Network.Wai.Handler.Warp.WithApplication
Paths_warp

if flag(include-warp-version)
other-modules: Paths_warp

default-language: Haskell2010
ghc-options: -Wall -threaded
Expand Down Expand Up @@ -285,7 +302,9 @@ benchmark parser
Network.Wai.Handler.Warp.RequestHeader
Network.Wai.Handler.Warp.Settings
Network.Wai.Handler.Warp.Types
Paths_warp

if flag(include-warp-version)
other-modules: Paths_warp

default-language: Haskell2010
build-depends:
Expand Down
Loading