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

Release Notes for v0.6 #116

Closed
ixti opened this issue Mar 28, 2014 · 6 comments · Fixed by #117
Closed

Release Notes for v0.6 #116

ixti opened this issue Mar 28, 2014 · 6 comments · Fixed by #117
Milestone

Comments

@ixti
Copy link
Member

ixti commented Mar 28, 2014

Summary
  • Rename HTTP::Request#method to HTTP::Request#verb (@krainboltgreene)
  • Add HTTP::ResponseBody class (@tarcieri)
  • Change API of response on HTTP::Client.request and "friends" (#get, #post, etc) (@tarcieri)
  • Add HTTP::Response#readpartial (@tarcieri)
  • Add HTTP::Headers class (@ixti)
  • Fix and improve following redirects (@ixti)
  • Add HTTP::Request#redirect (@ixti)
  • Add HTTP::Response#content_type (@ixti)
  • Add HTTP::Response#mime_type (@ixti)
  • Add HTTP::Response#charset (@ixti)
  • Improve error message upon invalid URI scheme (@ixti)
  • Consolidate errors under common HTTP::Error namespace (@ixti)
  • Add easy way of adding Authorization header (@ixti)
  • Fix proxy support (@hundredwatt)
  • Fix and improve query params handing (@jwinter)
  • Change API of custom MIME type parsers (@ixti)
  • Remove HTTP::Chainable#with_response (@ixti)
  • Remove HTTP::Response::BodyDelegator (@ixti)
  • Remove HTTP::Response#parsed_body (@ixti)
  • Bump up input buffer from 4K to 16K (@tarcieri)
Details
# Main API change you will mention is that `request` method and it's
# syntax sugar helpers like `get`, `post`, etc. now returns Response
# object instead of BodyDelegator:

response = HTTP.get "http://example.com"
raw_body = HTTP.get("http://example.com").to_s
parsed_body = HTTP.get("http://example.com/users.json").parse

# Second major change in API is work with request/response headers
# It is now delegated to `HTTP::Headers` class, so you can check it's
# documentation for details, here we will only outline main difference.
# Duckface (`[]=`) does not appends headers anymore

request[:content_type] = "text/plain"
request[:content_type] = "text/html"
request[:content_type] # => "text/html"

# In order to add multiple header values, you should pass array:

request[:cookie] = ["foo=bar", "woo=hoo"]
request[:cookie] # => ["foo=bar", "woo=hoo"]

# or call `#add` on headers:

request.headers.add :accept, "text/plain"
request.headers.add :accept, "text/html"
request[:accept] # => ["text/plain", "text/html"]

# Also, you can now read body in chunks (stream):

res = HTTP.get "http://example.com"
File.open "/tmp/dummy.bin", "wb" do |io|
  while (chunk = res.readpartial)
    io << chunk
  end
end
@ixti ixti added this to the v0.6 milestone Mar 28, 2014
@sferik
Copy link
Contributor

sferik commented Mar 28, 2014

We just need to summarize 206 commits since July 15. 😉

I can start working on this.

@sferik sferik self-assigned this Mar 28, 2014
@ixti
Copy link
Member Author

ixti commented Mar 28, 2014

Actually we can use this issue as a "common" notepad :D

@sferik
Copy link
Contributor

sferik commented Mar 28, 2014

Here’s my list. Let me know if you think anything should be added.

  • Rename HTTP::Request#method to HTTP::Request#verb (@krainboltgreene via 45af97f)
  • Add HTTP::ResponseBody class (@tarcieri)
  • Add HTTP::Headers class (@ixti)
  • Fix and improve following redirects (@ixti)
  • Add HTTP::Request#redirect (@ixti)
  • Add easy way of adding Authorization header (@ixti)
  • Fix proxy support (@hundredwatt)
  • Remove HTTP::Chainable#with_response (6223d90)

Feel free to add things any items you think are important that I might have missed.

@ixti
Copy link
Member Author

ixti commented Mar 28, 2014

Probably it worth mentioning backward incompatible changes, e.g.:

# before
res = HTTP.get("http://example.com/").response
body = HTTP.get("http://example.com/").to_s
parsed = res.parse_body

# now
res = HTTP.get("http://example.com/")
body = res.to_s
parsed = res.parse

@tarcieri
Copy link
Member

The response body class is actually HTTP::Response::Body, and it would be good to note it now supports #readpartial for incremental streaming of the response body.

@tarcieri
Copy link
Member

@ixti yes definitely, we should note there's no longer a BodyDelegator which otherwise delegates to the body as a string

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 a pull request may close this issue.

3 participants