Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Faraday patches #90

Closed
wants to merge 3 commits into from

2 participants

@hakanensari

I ran into a few issues while writing an adapter for Faraday.

Please check out the commit messages for a somewhat more detailed explanation.

hakanensari added some commits
@hakanensari hakanensari Avoid creating key if io doesn't respond to pos
Otherwise reset_pos subsequently raises No Method Error
4db7912
@hakanensari hakanensari Make dump_file and dump_chunks work with CompositeReadIO
Not sure how to go about explaining this in a short way.

This change was necessary to support streaming file uploads in Faraday
with HTTPClient. Its CompositeReadIO io object was not working with the
previous implementation, where you pass buffer as second argument.

Tests on your end are also passing, although I'm not sure if you have
file uploads covered.
4f959ef
@hakanensari hakanensari Some .gitignore plumbing f381cc0
@hakanensari hakanensari referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@nahi
Owner

Thanks for the patches! I want to merge these for Faraday integration but I have some questions. I'll add Qs into the commits.

@hakanensari

I will look again more carefully at this when I get a chance in the next few days, but very briefly, the send file test in Faraday still fails with 2.2.5. I also added a quick response to one of your questions in the commits.

@nahi
Owner

Yeah, sorry, 2.2.5 does not contain any change for that. It's still an open question...

@nahi
Owner

I close this ticket because of outdated versions.

@nahi nahi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 2, 2012
  1. @hakanensari

    Avoid creating key if io doesn't respond to pos

    hakanensari authored
    Otherwise reset_pos subsequently raises No Method Error
  2. @hakanensari

    Make dump_file and dump_chunks work with CompositeReadIO

    hakanensari authored
    Not sure how to go about explaining this in a short way.
    
    This change was necessary to support streaming file uploads in Faraday
    with HTTPClient. Its CompositeReadIO io object was not working with the
    previous implementation, where you pass buffer as second argument.
    
    Tests on your end are also passing, although I'm not sure if you have
    file uploads covered.
  3. @hakanensari

    Some .gitignore plumbing

    hakanensari authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 5 deletions.
  1. +2 −0  .gitignore
  2. +3 −5 lib/httpclient/http.rb
View
2  .gitignore
@@ -2,3 +2,5 @@
tags
pkg
coverage
+reports
+Gemfile.lock
View
8 lib/httpclient/http.rb
@@ -549,7 +549,7 @@ def set_content(body, boundary = nil)
def remember_pos(io)
# IO may not support it (ex. IO.pipe)
- @positions[io] = io.pos rescue nil
+ @positions[io] = io.pos if io.respond_to?(:pos)
end
def reset_pos(io)
@@ -557,15 +557,13 @@ def reset_pos(io)
end
def dump_file(io, dev)
- buf = ''
- while !io.read(@chunk_size, buf).nil?
+ while buf = io.read(@chunk_size)
dev << buf
end
end
def dump_chunks(io, dev)
- buf = ''
- while !io.read(@chunk_size, buf).nil?
+ while buf = io.read(@chunk_size)
dev << dump_chunk(buf)
end
end
Something went wrong with that request. Please try again.