Skip to content

Support providing a Content-Length to ContentSource #1892

@parsonsmatt

Description

@parsonsmatt

We are doing some pass-through requests in our application, where we make a request to S3 and then stream the response back to the client. We want to provide Content-Length headers, since S3 gives us those.

ContentSource only has the ConduitT, and does not provide a way to set the length, even when we know it.

We can provide this with a backwards-compatible pattern synonym and new constructor on Content.

data Content
    = ContentSourceWithLength !(Conduit () (Flush BB.Builder) (ResourceT IO) ()) !(Maybe Int)
    | etc

pattern ContentSource c <- ContentSourceWithLength c _ where
  ContentSource c = ContentSourceWithLength c Nothing

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions