fixed digest post data

This commit is contained in:
404
2012-08-13 16:50:40 +08:00
parent 1a950e8f85
commit da0d8d5ef8
5 changed files with 30 additions and 15 deletions
+3 -3
View File
@@ -22,9 +22,9 @@ module Qiniu
:auth_url => "https://acc.qbox.me/oauth2/token",
:rs_host => "http://rs.qbox.me:10100",
:io_host => "http://iovip.qbox.me",
:up_host => "http://m1.qbox.me:13019",
:pub_host => "http://m1.qbox.me:13012",
:eu_host => "http://m1.qbox.me:15000",
:up_host => "http://up.qbox.me",
:pub_host => "http://pu.qbox.me:10200",
:eu_host => "http://eu.qbox.me",
:client_id => "a75604760c4da4caaa456c0c5895c061c3065c5a",
:client_secret => "75df554a39f58accb7eb293b550fa59618674b7d",
:access_key => "",
+6 -5
View File
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
require 'uri'
require 'cgi'
require 'json'
require 'zlib'
require 'base64'
@@ -104,8 +105,8 @@ module Qiniu
def generate_query_string(params)
return params if params.is_a?(String)
total_param = params.map { |key, value| key.to_s+"="+value.to_s }
URI.escape(total_param.join("&"))
total_param = params.map { |key, value| %Q(#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s).gsub('+', '%20')}) }
total_param.join("&")
end
def crc32checksum(filepath)
@@ -119,10 +120,10 @@ module Qiniu
signature = uri.path
query_string = uri.query
signature += '?' + query_string if !query_string.nil? && !query_string.empty?
signature += "\n";
signature += "\n"
if params.is_a?(Hash)
total_param = params.map { |key, value| key.to_s+"="+value.to_s }
signature += total_param.join("&")
params_string = generate_query_string(params)
signature += params_string
end
hmac = HMAC::SHA1.new(secret_key)
hmac.update(signature)
+2 -1
View File
@@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
require 'cgi'
require 'json'
require 'qiniu/tokens/access_token'
@@ -21,7 +22,7 @@ module Qiniu
signature += '?' + query_string if !query_string.nil? && !query_string.empty?
signature += "\n";
if @params.is_a?(Hash)
total_param = @params.map { |key, value| key.to_s+"="+value.to_s }
total_param = @params.map { |key, value| %Q(#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s).gsub('+', '%20')}) }
signature += total_param.join("&")
end
signature
+2 -2
View File
@@ -8,8 +8,8 @@ module Qiniu
describe Auth do
before :all do
@username = "test@qbox.net"
@password = "test"
@username = "qboxtest"
@password = "qboxtest123"
code, data = Qiniu::RS::Auth.exchange_by_password!(@username, @password)
code.should == 200
+17 -4
View File
@@ -6,9 +6,11 @@ require 'rspec'
RSpec.configure do |config|
config.before :all do
# Qiniu::RS.establish_connection! :access_key => "3fPHl_SLkPXdioqI_A8_NGngPWVJhlDk2ktRjogH",
# :secret_key => "bXTPMDJrVYRJUiSDRFtFYwycVD_mjXxYWrCYlDHy"
=begin
Qiniu::RS.establish_connection! :access_key => "3fPHl_SLkPXdioqI_A8_NGngPWVJhlDk2ktRjogH",
:secret_key => "bXTPMDJrVYRJUiSDRFtFYwycVD_mjXxYWrCYlDHy"
=end
#=begin
Qiniu::RS.establish_connection! :access_key => "bE21M6FW9V7zAFrBY5psgKOKJQLiBj12qMWTpc57",
:secret_key => "uMo7Nyq_eDK_CuQ8_FYCxoTHQZqjiaPh-cbiKO7L",
:auth_url => "http://m1.qbox.me:13001/oauth2/token",
@@ -16,6 +18,17 @@ RSpec.configure do |config|
:io_host => "http://m1.qbox.me:13004",
:up_host => "http://m1.qbox.me:13019",
:pub_host => "http://m1.qbox.me:13012",
:eu_host => "http://m1.qbox.me:15000",
:eu_host => "http://m1.qbox.me:13050"
#=end
=begin
Qiniu::RS.establish_connection! :access_key => "k6N9zXGKUs7UFmJtPXLWOF4idSAgPL4xA6BApBd-",
:secret_key => "p77h4hLERjGPi1Aw4P_G5qHGMKcz1MeSz3CqnYMV",
:auth_url => "http://127.0.0.1:9100/oauth2/token",
:rs_host => "http://127.0.0.1:9400",
:io_host => "http://127.0.0.1:9200",
:up_host => "http://127.0.0.1:11200",
:pub_host => "http://127.0.0.1:10200",
:eu_host => "http://127.0.0.1:15000"
=end
end
end