convertResponse :: W.ResponseHeaders
                -- ^ Headers not in the response to send to the client (see 'standardHeaders')
                -> H.Response -- ^ Happstack response
                -> W.Response
convertResponse additionalHeaders hResp =
    case hResp of
      H.SendFile{H.sfOffset=off,H.sfCount=count,H.sfFilePath=filePath}
          ->
            let fp = W.FilePart off count
            in W.ResponseFile status headersNoCl filePath (Just fp)
      H.Response{H.rsBody=body}
          -> W.responseLBS status headers body
  where
  -- TODO description
    status = W.Status (H.rsCode hResp) ""
    headersNoCl =
        (additionalHeaders ++) $
        concatMap (\(H.HeaderPair k vs) -> map (\v -> (CI.mk k, v)) vs) $
        Map.elems (H.rsHeaders hResp)
    headers =
        case H.rsfLength (H.rsFlags hResp) of
          H.ContentLength ->
              ("Content-Length", B8.pack $ show $ BL.length $ H.rsBody hResp)
              : headersNoCl
          _ -> headersNoCl
convertResponse :: W.ResponseHeaders
                -- ^ Headers not in the response to send to the client (see 'standardHeaders')
                -> H.Response -- ^ Happstack response
                -> W.Response
convertResponse additionalHeaders hResp =
    case hResp of
      H.SendFile{H.sfOffset=off,H.sfCount=count,H.sfFilePath=filePath}
          ->
            let fp = W.FilePart off count
            in W.ResponseFile status headersNoCl filePath (Just fp)
      H.Response{H.rsBody=body}
          -> W.responseLBS status headers body
  where
  -- TODO description
    status = W.Status (H.rsCode hResp) ""
    headersNoCl =
        (additionalHeaders ++) $
        concatMap (\(H.HeaderPair k vs) -> map (\v -> (CI.mk k, v)) vs) $
        Map.elems (H.rsHeaders hResp)
    headers =
        case H.rsfLength (H.rsFlags hResp) of
          H.ContentLength ->
              ("Content-Length", B8.pack $ show $ BL.length $ H.rsBody hResp)
              : headersNoCl
          _ -> headersNoCl
convertResponse additionalHeaders hResp =
    case hResp of
      H.SendFile{H.sfOffset=off,H.sfCount=count,H.sfFilePath=filePath}
          ->
            let fp = W.FilePart off count
            in W.ResponseFile status headersNoCl filePath (Just fp)
      H.Response{H.rsBody=body}
          -> W.responseLBS status headers body
  where
  -- TODO description
    status = W.Status (H.rsCode hResp) ""
    headersNoCl =
        (additionalHeaders ++) $
        concatMap (\(H.HeaderPair k vs) -> map (\v -> (CI.mk k, v)) vs) $
        Map.elems (H.rsHeaders hResp)
    headers =
        case H.rsfLength (H.rsFlags hResp) of
          H.ContentLength ->
              ("Content-Length", B8.pack $ show $ BL.length $ H.rsBody hResp)
              : headersNoCl
          _ -> headersNoCl