2

I'm working on a project where I'll be sending lots of binary data (several images in one message) over HTTP POST to a RESTful interface.

I've looked into alternatives such as JSON, protobuff, thrift but found no conclusive comparisons of overhead introduced by these formats. Which one would you prefer to use in this case?

3
  • It's probably most efficient to not encode it at all, set the appropriate Content-Type and Content-Length headers and then just send it over the HTTP connection as the POST's body. Commented Dec 22, 2011 at 22:19
  • Thanks. But I also want to send some metadata with it, such as an API key or similar. I figured using a standard library is clean. But perhaps you suggest coming up with a simple internal format to parse the byte array from HTTP POST's body? Commented Dec 22, 2011 at 22:23
  • Then just use multipart/form-data. Commented Dec 22, 2011 at 22:32

1 Answer 1

1

If you really need to do that all as part of a single HTTP POST, then I would first be more concerned about reliability and functionality. Efficiency is all going to be relative to what you are sending. If it is images in an already compressed format/container, then it is very likely you are not going to see a good percentage difference in efficiency without sacrificing something else. So in my opinion, probably the most effective thing to look into would be to use MIME encoding of your content in the POST which would mean encoding binary's using Base64. Using this you have the benefit that almost any development platform these days will either have this functionality either built in or will be easily available in external libraries for doing MIME / Base64. Sticking with highly used standards like these can make it easy to support a wide user base. Some links for reference:

http://en.wikipedia.org/wiki/MIME

http://en.wikipedia.org/wiki/Base64

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.