Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign Body and BodyParts APIs #1238

Closed
slandelle opened this issue Jun 24, 2013 · 13 comments
Closed

Redesign Body and BodyParts APIs #1238

slandelle opened this issue Jun 24, 2013 · 13 comments

Comments

@slandelle
Copy link
Member

Problems with Body and BodyPart current APIs:

  • too much complexity with too many methods and optional attributes
  • can't set up transferEncoding and fileName (for Content-Disposition header)

=> Let's have one single method that explicitly takes different types. Have those types propose a builder pattern for non Scala users who are not familiar with Option and case classes copy

@ghost ghost assigned slandelle Jun 24, 2013
@slandelle
Copy link
Member Author

New API:

  • Body:
    • .body(ELFileBody(filePath))
    • .body(StringBody(string))
    • .body(RawFileBody(filePath))
    • .body(ByteArrayBody(bytes))
    • .body(InputStreamBody(is))
  • BodyPart:
    • .bodyPart(RawFileBodyPart(name, filePath, contentType))
    • .bodyPart(ELFileBodyPart(name, filePath))
    • .bodyPart(StringBodyPart(name, value))
    • .bodyPart(ByteArrayBodyPart(name, bytes, contentType))
    • .bodyPart(FileBodyPart(name, filePath, contentType))
    • new BodyPart methods: withCharset, withFileName, withContentId, withTransferEncoding to override defaults

@heim
Copy link

heim commented Jun 25, 2013

I'm seeing that the Content-Disposition header is not set correctly unless you specify withFileName when I'm using .bodyPart(RawFileBodyPart("fieldName", "fileName.foo", "application/foo")) . More specifically the "fieldName"-part is not present in the header.

@slandelle
Copy link
Member Author

Yep, that's intended. Form multipart is not the only use case for multipart. For example, some people use Gatling for SOAP MTOM, where Content-Disposition is not expected.

@heim
Copy link

heim commented Jun 26, 2013

👍

@slandelle
Copy link
Member Author

So, working fine?

@heim
Copy link

heim commented Jun 26, 2013

Like a charm!

Sent from Mailbox for iPhone

On Wed, Jun 26, 2013 at 8:23 AM, Stephane Landelle
notifications@github.com wrote:

So, working fine?

Reply to this email directly or view it on GitHub:
#1238 (comment)

@slandelle
Copy link
Member Author

Thanks for your feedback!

ateam

@heim
Copy link

heim commented Jun 26, 2013

Just another comment. It is not very obvious (at least to me) that to make the name-param appear in the Content-Disposition-header you must set withFileName, but you are maybe planning to make a helper-method for fileuploads?

@slandelle
Copy link
Member Author

Don't know yet. I'm afraid that would bring more confusion. The first thing we'll do when we'll release Gatling 2 is to properly document everything.

@cfraga
Copy link

cfraga commented Jul 30, 2013

I was trying to follow the documentation examples on json bodies and it took me a long while to realize how the API had changed, since the specific part on the wiki about the body in the request is outdated. I only got it to work when i found this issue. Since i am new in github i dont know if its possible to suggest edits on wiki pages. If so i would be more than happy to update the body parameters section to reflect these changes.

@slandelle
Copy link
Member Author

Except for the Gatling 2 page, the whole wiki targets Gatling 1 (Gatling 2 is still in milestone phase). Github can't display multiple versions of the same page. We'll migrate the documentation out of Github's wiki in a next version.

@slandelle
Copy link
Member Author

See here: https://github.com/excilys/gatling/wiki/Gatling-2#wiki-bodies

The link is in bold, in the top part of the right menu, can't do better for now.

@cfraga
Copy link

cfraga commented Jul 30, 2013

Yeah, i ended up getting to that Gatling 2 page and it answered all my questions. It was my mistake, i thought the documentation was already referring to Gatling 2. Thanks for the quick reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants