fileRangeSized :: H.Status -> H.ResponseHeaders
               -> Maybe FilePart -> Maybe HeaderValue -> Integer
               -> (H.Status, H.ResponseHeaders, Integer, Integer)
fileRangeSized s0 hs0 mPart mRange fileSize = (s, hs, beg, len)
  where
    (beg, end, len, isEntire) = checkPartRange fileSize mPart mRange
    hs1 = addContentLength len hs0
    hs | isEntire  = hs1
       | otherwise = addContentRange beg end fileSize hs1
    s  | isEntire  = s0
       | otherwise = H.status206
fileRangeSized :: H.Status -> H.ResponseHeaders
               -> Maybe FilePart -> Maybe HeaderValue -> Integer
               -> (H.Status, H.ResponseHeaders, Integer, Integer)
fileRangeSized s0 hs0 mPart mRange fileSize = (s, hs, beg, len)
  where
    (beg, end, len, isEntire) = checkPartRange fileSize mPart mRange
    hs1 = addContentLength len hs0
    hs | isEntire  = hs1
       | otherwise = addContentRange beg end fileSize hs1
    s  | isEntire  = s0
       | otherwise = H.status206
fileRangeSized s0 hs0 mPart mRange fileSize = (s, hs, beg, len)
  where
    (beg, end, len, isEntire) = checkPartRange fileSize mPart mRange
    hs1 = addContentLength len hs0
    hs | isEntire  = hs1
       | otherwise = addContentRange beg end fileSize hs1
    s  | isEntire  = s0
       | otherwise = H.status206