Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Replace yajl with multi_json in JSONResponse middleware #238

Merged
merged 4 commits into from

4 participants

@sferik

Following-up on this discussion: bf80032#commitcomment-3485020

@sferik sferik referenced this pull request from a commit
@igrigorik add json response middleware bf80032
@igrigorik igrigorik merged commit db22164 into igrigorik:master
@igrigorik
Owner

lgtm - thanks!

@sferik sferik referenced this pull request in tweetstream/tweetstream
Closed

dependency yajl-ruby doesn't work in jruby #134

@jure

Awesome! Any chance we can get a release of this @igrigorik?

@stve

hi @igrigorik, any chance of this getting a release soon? Thanks!

@igrigorik
Owner

Done! Apologies about the wait.

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
12 Gemfile
@@ -1,14 +1,14 @@
-source "http://rubygems.org"
+source 'http://rubygems.org'
gemspec
group :benchmark do
+ gem 'curb'
+ gem 'excon'
gem 'httparty'
gem 'rest-client'
- gem 'tach', '0.0.8'
- gem 'typhoeus'
gem 'sinatra'
gem 'streamly_ffi'
- gem 'curb'
- gem 'excon'
-end
+ gem 'tach', '>= 0.0.8'
+ gem 'typhoeus'
+end
View
2  Rakefile
@@ -7,4 +7,4 @@ desc "Run all RSpec tests"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
-task :test => [:spec]
+task :test => [:spec]
View
36 em-http-request.gemspec
@@ -1,33 +1,33 @@
# -*- encoding: utf-8 -*-
-$:.push File.expand_path("../lib", __FILE__)
-require "em-http/version"
+$:.push File.expand_path('../lib', __FILE__)
+require 'em-http/version'
Gem::Specification.new do |s|
- s.name = "em-http-request"
+ s.name = 'em-http-request'
s.version = EventMachine::HttpRequest::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Ilya Grigorik"]
- s.email = ["ilya@igvita.com"]
- s.homepage = "http://github.com/igrigorik/em-http-request"
- s.summary = "EventMachine based, async HTTP Request client"
+ s.email = ['ilya@igvita.com']
+ s.homepage = 'http://github.com/igrigorik/em-http-request'
+ s.summary = 'EventMachine based, async HTTP Request client'
s.description = s.summary
- s.rubyforge_project = "em-http-request"
+ s.rubyforge_project = 'em-http-request'
- s.add_dependency "eventmachine", ">= 1.0.3"
- s.add_dependency "addressable", ">= 2.3.4"
- s.add_dependency "http_parser.rb", ">= 0.6.0.beta.2"
- s.add_dependency "em-socksify", ">= 0.3"
- s.add_dependency "cookiejar"
+ s.add_dependency 'addressable', '>= 2.3.4'
+ s.add_dependency 'cookiejar'
+ s.add_dependency 'em-socksify', '>= 0.3'
+ s.add_dependency 'eventmachine', '>= 1.0.3'
+ s.add_dependency 'http_parser.rb', '>= 0.6.0.beta.2'
- s.add_development_dependency "rspec"
- s.add_development_dependency "rake"
- s.add_development_dependency "rack"
- s.add_development_dependency "yajl-ruby"
- s.add_development_dependency "mongrel", "~> 1.2.0.pre2"
+ s.add_development_dependency 'mongrel', '~> 1.2.0.pre2'
+ s.add_development_dependency 'multi_json'
+ s.add_development_dependency 'rack'
+ s.add_development_dependency 'rake'
+ s.add_development_dependency 'rspec'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
- s.require_paths = ["lib"]
+ s.require_paths = ['lib']
end
View
4 examples/fibered-http.rb
@@ -27,13 +27,13 @@ def async_fetch(url)
Fiber.new{
puts "Setting up HTTP request #1"
- data = async_fetch('http://0.0.0.0/')
+ data = async_fetch('http://0.0.0.0/')
puts "Fetched page #1: #{data.response_header.status}"
puts "Setting up HTTP request #2"
data = async_fetch('http://www.yahoo.com/')
puts "Fetched page #2: #{data.response_header.status}"
-
+
puts "Setting up HTTP request #3"
data = async_fetch('http://non-existing.domain/')
puts "Fetched page #3: #{data.response_header.status}"
View
2  lib/em-http/core_ext/bytesize.rb
@@ -3,4 +3,4 @@
class String
def bytesize; self.size; end
end
-end
+end
View
2  lib/em-http/http_status_codes.rb
@@ -54,4 +54,4 @@ module HttpStatus
510 => 'Not Extended'
}
end
-end
+end
View
4 lib/em-http/middleware/json_response.rb
@@ -1,11 +1,11 @@
-require 'yajl'
+require 'multi_json'
module EventMachine
module Middleware
class JSONResponse
def response(resp)
begin
- body = Yajl::Parser.parse(resp.response)
+ body = MultiJson.load(resp.response)
resp.response = body
rescue Exception => e
end
View
10 lib/em-http/version.rb
@@ -1,5 +1,5 @@
-module EventMachine
- class HttpRequest
- VERSION = "1.1.0"
- end
-end
+module EventMachine
+ class HttpRequest
+ VERSION = "1.1.0"
+ end
+end
View
2  spec/helper.rb
@@ -3,7 +3,7 @@
require 'em-http'
require 'em-http/middleware/oauth2'
-require 'yajl'
+require 'multi_json'
require 'stallion'
require 'stub_server'
View
4 spec/middleware_spec.rb
@@ -117,11 +117,11 @@ def request(client, head, body)
context "jsonify" do
class JSONify
def request(client, head, body)
- [head, Yajl::Encoder.encode(body)]
+ [head, MultiJson.dump(body)]
end
def response(resp)
- resp.response = Yajl::Parser.parse(resp.response)
+ resp.response = MultiJson.load(resp.response)
end
end
View
4 spec/stallion.rb
@@ -276,11 +276,11 @@ def self.call(env)
# Take the initial line from the upstream response
session.write client.gets
-
+
if proxy
session.write "X-Proxy-Auth: #{proxy}\r\n"
end
-
+
# What (absolute) uri was requested? Send it back in a header
session.write "X-The-Requested-URI: #{destination}\r\n"
Something went wrong with that request. Please try again.