Skip to content

Multipart form files only accept seekable streams #1398

@ordinaryorange

Description

@ordinaryorange

I've a situation where I need to pass in a PipeReader stream for use a MiltiPartItem form files for a POST request.

However I notice the current writeMultipart and CombinedStream implementations lean on the Stream.Length property which is where things fail.

The Length property assumes provided streams are seekable, which PipeReader (and others) are not.

In my testing I've removed all the Stream.Lengh references, (which also means the CombinedStream cant calculate it's length) and removed the assignment of length during request building.

Requests are still issued to and accepted by the server, so it initially seems ok to permit non seekable streams

Thoughts

  • This is using the current WebRequest implementation, and I've no idea if this will work in HttpClient Use System.Net.Http.HttpClient #1392
  • I'm unsure if it is a requirement for a POST request to have a Length.
  • Are non seekable streams for multipart items even a valid idea for inclusion
  • Anything else I've overlooked

Thoughts please, as to if this would be a valid inclusion ?

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