Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

confusion around request body #174

Closed
ghost opened this Issue · 10 comments

2 participants

@ghost

hey
i am confused around what type of object a request body should be. it seems at times it could be a String(in past experience), and at other times it could be IO-like(StringIO or similar). is there a consensus on what it should be between all adapters?
IO-like makes the most sense to me.

@ghost

webmachine-test seems to assume it is a String(iirc).

@Asmod4n
Collaborator

You should always be able to call #each or #to_s on a request.body

@ghost

i guess that means Enumerable(#each) or IO(#to_s) then.

@lgierth

I have looked into this to some extent recently, and the body should be nil or respond to at least one of #each, #to_s, and #call.

@Asmod4n
Collaborator

Most adapters have their own RequestBody class, if they have one you get #each and #to_s.

@Asmod4n
Collaborator

And with request.has_body? you can check if you have a request.body: https://github.com/seancribbs/webmachine-ruby/blob/master/lib/webmachine/request.rb#L52

@lgierth

#has_body? seems to be a bit off. With the streaming encoders as a body you don't neccessarily know the length, and none of them even responds to #empty?.

@Asmod4n
Collaborator

This is about request.body, not response.body.

@lgierth

Ooops. Forget all I said then.

@ghost

alright, thanks all!

@ghost ghost closed this
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.