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

Make Urlencoded component into an IO object #14

Merged
merged 1 commit into from
May 11, 2017
Merged

Make Urlencoded component into an IO object #14

merged 1 commit into from
May 11, 2017

Conversation

janko
Copy link
Member

@janko janko commented May 11, 2017

In #12 I forgot to also make the Urlencoded component into an IO object, so this PR fixes this inconsistency.

The reason why I need this is because I want to change the following HTTP.rb code:

def make_request_body(opts, headers)
  request_body =
    case
    # ...
    when opts.form
      form = HTTP::FormData.create opts.form
      headers[Headers::CONTENT_TYPE]   ||= form.content_type
      headers[Headers::CONTENT_LENGTH] ||= form.content_length
      form.to_s
    # ...
  # ...
end

into

def make_request_body(opts, headers)
  request_body =
    case
    # ...
    when opts.form
      form = HTTP::FormData.create opts.form
      headers[Headers::CONTENT_TYPE] ||= form.content_type
      form
    # ...
  # ...
end

So then I need the result of FormData.create to be an IO object, regardless of whether it's a FormData::Multipart or FormData::Urlencoded.

Following recent transformations of other components into IO objects:

* FormData::Multipart
* FormData::Multipart::Param
* FormData::Part
* FormData::File
@ixti ixti merged commit 64c7721 into httprb:master May 11, 2017
@ixti
Copy link
Member

ixti commented May 11, 2017

Thanks!

@janko janko deleted the make-urlencoded-an-io branch May 11, 2017 15:18
@ixti
Copy link
Member

ixti commented May 11, 2017

Released as 2.0.0.pre2

@janko
Copy link
Member Author

janko commented May 11, 2017

@ixti Awesome, thank you!

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Dec 9, 2017
This version is required by newer ruby-http gem 3.0.0.

Upstream changes: (from CHANGES.md)

## 2.0.0 (2017-10-01)

* [#17](httprb/form_data#17)
  Add CRLF character to end of multipart body.
  [@mhickman][]


## 2.0.0.pre2 (2017-05-11)

* [#14](httprb/form_data#14)
  Enable streaming for urlencoded form data.
  [@janko-m][]


## 2.0.0.pre1 (2017-05-10)

* [#12](httprb/form_data#12)
  Enable form data streaming.
  [@janko-m][]
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Mar 17, 2018
## 2.1.0 (2018-03-05)

* [#21](httprb/form_data#21)
  Rewind content at the end of `Readable#to_s`.
  [@janko-m][]

* [#19](httprb/form_data#19)
  Fix buffer encoding.
  [@HoneyryderChuck][]


## 2.0.0 (2017-10-01)

* [#17](httprb/form_data#17)
  Add CRLF character to end of multipart body.
  [@mhickman][]


## 2.0.0.pre2 (2017-05-11)

* [#14](httprb/form_data#14)
  Enable streaming for urlencoded form data.
  [@janko-m][]


## 2.0.0.pre1 (2017-05-10)

* [#12](httprb/form_data#12)
  Enable form data streaming.
  [@janko-m][]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants