Comments (24)
@zackxu1 it's documented here: https://github.com/httprb/http/wiki/Passing-Parameters
from http.
Or possibly an API like #post_file
from http.
@tarcieri Yes, that would be nice.
FYI, I’ve been working on replacing Faraday with the HTTP gem on a branch in the Twitter gem. I’ve got pretty much everything working except for posting files (this branch also depends on JSON parsing, which I’ve hacked together in a local branch).
from http.
Nice, someone actually pinged me on Faraday support for the HTTP gem yesterday
from http.
That would be nice too.
I haven’t done proper benchmarking but the Twitter test suite (about 900 examples that make about 368 HTTP requests) runs about 4X faster in the http
branch than in master
(with Faraday). Obviously, the bottleneck of any HTTP API wrapper is network latency but this seems like a pretty significant reduction in request overhead.
I’d be curios to see how the performance would compare using an HTTP gem adapter for Faraday. I suspect it would be slower than using just the HTTP gem (sans Faraday). I think Faraday’s slowness is a result of having a middleware stack that each request must pass through.
I do think writing a Faraday adapter would make it easier for people to try the HTTP gem in their existing clients.
from http.
https://github.com/nicksieger/multipart-post actually looks like it can be used anywhere.
from http.
I don't think this is required for 0.6
from http.
I agree, this is more of a nice-to-have for v0.6 but I think it’s a requirement for v1.0.
from http.
I’ve moved this issue out of the v0.6 milestone and created a new v1.0 milestone.
from http.
Seems good
from http.
An issue with #post_file
is that it will make API call look pretty strange when you need to upload more than one file or when you need to post some form values as well. I propose to stay with the same API we have now, we just need to recognize part of :form
:
HTTP.post(url, :form => {
:title => "Foobar",
:file => HTTP::UploadIO.new(path_to_file, optional_mime_type)
})
Something very similar to Faraday actually ;))
from http.
@ixti That would be acceptable to me. What is needed to support this?
from http.
@sferik I guess some spare time ;)) Other than that I don't see any problems here :D
from http.
@ixti 👍
from http.
@Asmod4n multipart-post uses Net::HTTP
😝
@ixti I’ve merged the http
branch into master
. This issue is the only thing stopping me from releasing the next major version of the twitter
gem. Any idea when you might get a chance to work on this?
from http.
@sferik will try to jimp on this during this weekend.
from http.
@ixti \o/
from http.
@ixti 👍
from http.
@sferik what i was trying to say was multipart-post looks like it doesn't depent on anything and can be injected into any IO library, namely https://github.com/nicksieger/multipart-post/blob/master/lib/parts.rb seams to be independent of Net::HTTP and can be hooked into this gem :)
from http.
@Asmod4n Ah, very nice. :)
from http.
I have started working on this issue, but not yet finished :D Will finish during this week.
We will not use multipart-post
. Although it's really might be possible to couple it with HTTP gem, I dislike it's code and would like to come with our own solution.
from http.
@ixti Awesome! If this code is independent of the http
gem, do you think it makes sense to package it as a separate gem (suggested name: http-multipart
)? This would force us to have a clean separation and allow people to use it with other Ruby HTTP libraries.
from http.
@sferik Makes sense. Although I would like to first build it as part of HTTP gem - and then simply extract those classes out :D
Re suggested name. Actually a more appropriate name will be http-form
or probably http-form_data
. A sneak peek to the API:
# Usage inside with HTTP Gem:
HTTP.post(some_url, :form => {
:username => "ixti",
:avatar => HTTP::FormData::File.new("/path/to/file.jpg"),
:cv => HTTP::FormData::File.new(io, :filename => "cv.pdf")
})
# Standalone usage:
form = HTTP::FormData.new({
:username => "ixti",
:avatar => HTTP::FormData::File.new("/path/to/file.jpg"),
:cv => HTTP::FormData::File.new(io, :filename => "cv.pdf")
})
form.to_s # => returns HTTP request multipart body
from http.
@ixti The above is really helpful. It would be even more helpful if it's in the README of the gem. Thank you.
from http.
Related Issues (20)
- feature request: happy eyeballs
- Can we update to llhttp-ffi 0.5.0 HOT 2
- access ssl certificate details? HOT 4
- Issues running it on Mac Intel (12.6) HOT 3
- SSLERROR occurred when running http method in the executable file: certificate verify failed. HOT 1
- 403 and 404 responses for valid URLs HOT 7
- raise error when invalid hash is passed to timeout HOT 1
- Are you open to include rspec_matchers? HOT 18
- File descriptor / socket leak when timeout occurs during initialization
- How to query the remote server address? HOT 1
- Make HTTP::Feature work like rack middleware HOT 10
- Remove auth header after following a redirect to a different origin
- Support HTTP headers streaming HOT 2
- Timeout redesign for 6.x HOT 4
- Fix Base64 dependency warning HOT 4
- Version 5.x bump? HOT 3
- project level timeout HOT 2
- `HTTP::Response::Body#each` and `BUFFER_SIZE`
- Feature Request: Better Control of Logging for Binary Request Body / Response Body
- Bug: Using Logger Breaks Request Streaming
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http.