elixir-reverse-proxy icon indicating copy to clipboard operation
elixir-reverse-proxy copied to clipboard

Proxying uploads and downloads

Open Lazarus404 opened this issue 9 years ago • 4 comments

Is this library capable of proxying uploaded and downloaded files between Plug and the HTTP client? If so, are their any examples of these?

Thanks, Lee

Lazarus404 avatar Apr 08 '16 10:04 Lazarus404

Hi @Lazarus404! Sorry for the delay.

I do not have any examples of this, and as of now, this isn't something that I've tested or looked into at any depth. That being said, I'd be more than happy to help correct any issues that arise.

slogsdon avatar Apr 15 '16 04:04 slogsdon

Hi slogsdon,

Do you have any notion of how to get started with it? Any ideas for pointers? There's a disconnect in my brain of taking the stream from one down/upload and piping it to another down/upload. It'd be a pretty powerful feature, though, imho.

Lazarus404 avatar Apr 15 '16 04:04 Lazarus404

I believe this should happen automagically via regular HTTP requests and responses since Plug only considers request/response bodies as being of type iolist.

For uploads, we read the request body from the client and pass it to the upstream. Granted, we may not be reading the entire request body at the moment.

For downloads, the upstream responds, and we take the body of the upstream response and set it as the client response.

slogsdon avatar Apr 15 '16 05:04 slogsdon

Thanks. I'​ll have a play and will report back with something that works when I have it.

Lazarus404 avatar Apr 15 '16 05:04 Lazarus404