Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Add support for specifying ParrotRequest body as a ByteArrayInputStream #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cahlbin
Copy link

@cahlbin cahlbin commented Feb 23, 2015

This allows sending parrot requests with a body that are to be interpreted as Content-Type: application/octet-stream.

The choice of requiring a ByteArrayInputStream vs any InputStream was simply because it made the allocation of the ChannelBuffer simple, because then InputStream.available() can be used reliably, and in favor over more complex allocation/copying of the InputStream to a Netty ChannelBuffer.

This allows sending parrot requests with a body that are to be
interpreted as Content-Type: application/octet-stream.
httpRequest.setHeader(CONTENT_LENGTH, buffer.readableBytes)
httpRequest.setContent(buffer)
if ((request.method == "POST" || request.method == "PUT") &&
(request.bodyInputStream.isDefined || request.body.length > 0)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have request.bodyInputStream.isDefined -- what does it do that request.body.length > 0 doesn't? Is it that we want to support zero length messages?

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants