Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added httparty Proxy setup if var exists. #10

Closed
wants to merge 2 commits into from

1 participant

@kitplummer

The added test doesn't test the proxy, just ensures it didn't break existing functionality. Would be cool to get this upstream so we don't have to maintain our own gem. :) Let me know if you have any thoughts/ideas on testing further. FlowDock kicks ass, we just need to be able to write to our stream/chat from behind our proxy server.

@kitplummer

Oops. Didn't mean to send you the branch with our "custom" gem mods. Sorry 'bout that.

@kitplummer kitplummer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  Gemfile
@@ -1,7 +1,7 @@
source "http://rubygems.org"
# Add dependencies required to use your gem here.
-gem "httparty", "~> 0.7"
+gem "httparty", "~> 0.6.1"
gem "multi_json"
# Add dependencies to develop your gem here.
View
2  VERSION
@@ -1 +1 @@
-0.2.0
+0.2.0.maestro
View
2  flowdock.gemspec
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = "flowdock"
- s.version = "0.2.0"
+ s.version = "0.2.0.maestro"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Antti Pitk\u{e4}nen"]
View
10 lib/flowdock.rb
@@ -7,6 +7,14 @@ module Flowdock
class Flow
include HTTParty
+
+ ##
+ # Accommodate an HTTPS proxy setting
+ if proxy = ENV['HTTPS_PROXY']
+ proxy = URI.parse(proxy)
+ http_proxy proxy.host, proxy.port
+ end
+
class InvalidParameterError < StandardError; end
class ApiError < StandardError; end
@@ -95,7 +103,7 @@ def handle_response(resp)
unless resp.code == 200
begin
# should have JSON response
- json = MultiJson.decode(resp.body)
+ json = MultiJson.load(resp.body)
errors = json["errors"].map {|k,v| "#{k}: #{v.join(',')}"}.join("\n") unless json["errors"].nil?
raise ApiError, "Flowdock API returned error:\nStatus: #{resp.code}\n Message: #{json["message"]}\n Errors:\n#{errors}"
rescue MultiJson::DecodeError
View
8 spec/flowdock_spec.rb
@@ -13,6 +13,14 @@
@flow = Flowdock::Flow.new(:api_token => "")
}.should raise_error(Flowdock::Flow::InvalidParameterError)
end
+
+ it "should succeed with proxy env set" do
+ ENV['HTTPS_PROXY'] = "https://localhost:9999/"
+ lambda {
+ @flow = Flowdock::Flow.new(:api_token => "test")
+ }.should_not raise_error
+ end
+
end
describe "with sending Team Inbox messages" do
Something went wrong with that request. Please try again.