Akshay Rawat
Akshay Rawat

Reputation: 4784

Parsing HTTP multipart response body in Ruby (outside Rack)

I'm trying to use RestClient and Faraday to query an endpoint which returns multiple files in a multipart response. How do I parse the multipart envelopes in the response body? Rack::Utils::Multipart.parse_multipart would have done it, but in my case, this is outside of Rack. I'm open to using a different HTTP client if its helps.

Upvotes: 1

Views: 1365

Answers (1)

fny
fny

Reputation: 33587

Almost none of the popular HTTP clients, in almost any language, handle multipart responses from a server. In fact I'd be surprised if you can easily find HTTP servers with baked in multipart response capabilities. It's just not a common use case.

You'll find the converse true though, most HTTP servers handle multipart responses built from clients.

The good news is that "multipart" is just content type like XML or JSON, so you should be able to attach any old multipart parser to the response body after you've made the request with your favorite HTTP client.

Some parsers to consider:

Upvotes: 2

Related Questions