lostisland / hurley Goto Github PK
View Code? Open in Web Editor NEWDEAD project, don't use
License: MIT License
DEAD project, don't use
License: MIT License
query = { time: Time.now, fred: "hello")
In httpclient i used to be able to do httpclient.get(uri,query). This worked nicely.
In Hurley i tried the following:
c=Hurley::Cleint.new url="https://datadrop.wolframcloud.com/api/v1.0/Add?"
c.get(Hurley::Query::Flat.new(query))
this comes close to working but strips the ? from the url.
Eventually i had to do the following:
q="https://datadrop.wolframcloud.com/api/v1.0/Add?"+ Hurley::Query::Flat.new(qdata).to_s
res=Hurley.get(q)
this does not seem to in keeping with the style of Hurley... Any suggestions for improving the handling of my hash structured query or keeping the question mark in the url?
Hey guys,
So I'm trying to use Hurley and I have to work with one API endpoint which uses HTTP Basic Auth. It keeps giving me access denied via Hurley but if I copy / paste the URL I generate with the https://username:[email protected]/api/end/point.json
response = @client.get("https://#{username}:#{password}@rubygems.org/api/v1/api_key.#{format}")
puts response.status_code
puts response.body
and I'm getting:
401
HTTP Basic: Access denied.
Pasting the result of "https://#{username}:#{password}@rubygems.org/api/v1/api_key.#{format}"
works though.
Setting an open and request timeout is something it would be great to have.
Line 45 in query.rb causes a crash if pair
is nil
, which can happen in the (possibly invalid but seen in the wild) case where the query string contains &&.
def parse_query(raw_query)
raw_query.to_s.split(AMP).each do |pair|
escaped_key, escaped_value = pair.split(EQ, 2)
key = CGI.unescape(escaped_key)
value = escaped_value ? CGI.unescape(escaped_value) : nil
send(:decode_pair, key, value)
end
end
Could easily fix by simply wrapping the block in if pair != nil
, but maybe there's a nicer ruby-like to do it (still pretty new to it)?
For future reference, would an immediate pull-request be preferred to raising an issue like this?
Why in hurley.rb this code needed?
MUTEX = Mutex.new
def self.default_client
@default_client ||= mutex { Client.new }
end
It looks, that in hurley repository there is no code with threads, which share same data, which must be locked.
It would be appreciated if an update the gem on ruby gems to fix basic auth and crashes when strings contain &&
could be pushed. Thanks!
I don't know if this is a desired behavior of the Test connection, but it is one that made a lot of sense when working with Faraday. When defining multiple stubs for the same URI, only the first one gets used by the connection and the subsequent responses aren't used, even when the client perform multiple requests
connection.get('/test') { [200, {}, 'foo'] }
connection.get('/test') { [200, {}, 'bar'] }
client.get('/test').body # => 'foo'
client.get('/test').body # => Expected to be 'bar', but it's 'foo'.
Is this the expected behavior of some oversight when porting the API from Faraday?
This project is incomplete, and isn't seeing any new work. I don't have any time to work on it, and unfortunately need to shut it down :( I'm not going to yank any gem versions, but I won't be replying to issues or pull requests from here on out.
You're probably better off with Faraday if you can't decide which of ruby's many http clients you want to use.
Streaming response bodies in response to certain status codes is broken, particularly with get requests. This is due to the fact that the body is read in perform_request, before the response status and headers are available.
The status code is always null and callbacks that filter on a given status code are never called. Working on a PR that fixes this.
I've got an extensive middleware stack used in my production Faraday code, including
Having a unified interface for this in Faraday was nice. Are you planning on offering the same kind of functionality in Hurley?
The README says that one can:
# Change it globally.
Hurley.default = Hurley::Query::Flat
Although this is not implemented (or has been removed). In order to globally change it, I had to monkey patch:
module Hurley
class Query
def self.default
@default ||= Flat
end
end
end
Found an issue where flat parameters are discarded when passing in a URL to client.get. Specifically, I'm calling client.get(url) with an absolute URL that has a repeated parameter. Even though the client instance is configured to use the flat encoder, I'm seeing only the last value.
Looks like client.request is calling URL.join() to merge the URL with the base URL (in this case the base is null.) This is where it breaks:
Example:
Hurley::Url.join(nil, 'https://www.foo.com?a=b&a=b2')
#<Hurley::Url https://www.foo.com?a=b2>
Notice only the last value of a is preserved. Expected result is that both pairs would be retained.
Hey,
I was wondering what the interest would be in having a Hurley Typhoeus connection made and how best to submit that to Lost Island for review / use.
If you could share any thoughts or preferences on that, I'd love to work on that as I really enjoy working with Hurley over other clients
Hey there! Ran the following steps to see whether hurley
would allow me past a redirection limitation I was hitting with open-uri
, but instead ran into this error:
[1] pry(main)> require 'hurley'
=> true
[2] pry(main)> Hurley.get("http://github.com")
TypeError: can't convert Net::ReadAdapter into String
from org/jruby/ext/stringio/StringIO.java:143:in `initialize'
Works fine if I run on MRI 2.1.5, but unfortunately my target app is JRuby-based.
JRuby version:
jruby 1.7.16.1 (1.9.3p392) 2014-10-28 4e93f31 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_20-b26 [darwin-x86_64]
Hurley::Response.location doesn't copy over the body_receiver to the new request. Bodies won't be received if the initial response contains a redirect.
Will send PR shortly.
Do you have any thoughts about the best way for Hurley adapter gems to run integration tests?
It's really nice that Hurley::Test::Integration has moved into the lib directory (which saves nastiness like this):
faraday_gem_location = Gem.loaded_specs['faraday'].gem_dir
integration_location = File.join(faraday_gem_location, 'test', 'adapters', 'integration')
require integration_location
However, what's the best way for the gems to spin up the server and trigger the tests? This probably works but is ugly:
adapter-gem/script/test:
#!/usr/bin/env bash
hurley_path=`bundle show hurley_path`
$hurley_path/script/test $@
adapter-gem/script/server:
#!/usr/bin/env bash
hurley_path_path=`bundle show hurley_path`
$hurley_path_path/script/server $@
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.