我有一个错误" RangeError:RangeError"当我通过我的网络服务发布文件时。
请参阅下面的错误堆栈:
RangeError:RangeError
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/utils.rb:135:in `normalize_params'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/utils.rb:163:in `normalize_params'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/utils.rb:122:in `block in parse_nested_query'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/utils.rb:119:in `each'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/utils.rb:119:in `parse_nested_query'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/request.rb:371:in `parse_query'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/request.rb:215:in `POST'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/methodoverride.rb:39:in `method_override_param'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/methodoverride.rb:27:in `method_override'
/home/greg/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/methodoverride.rb:15:in `call'
/home/greg/.rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/show_exceptions.rb:25:in `call'
/home/greg/.rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:182:in `call'
/home/greg/.rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:2013:in `call'
/home/greg/.rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `block in call'
/home/greg/.rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:1787:in `synchronize'
/home/greg/.rvm/gems/ruby-2.3.1/gems/sinatra-1.4.7/lib/sinatra/base.rb:1487:in `call'
/home/greg/.rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/connection.rb:86:in `block in pre_process'
/home/greg/.rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/connection.rb:84:in `catch'
/home/greg/.rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/connection.rb:84:in `pre_process'
/home/greg/.rvm/gems/ruby-2.3.1/gems/thin-1.7.0/lib/thin/connection.rb:50:in `block in process'
请参阅下面的代码:
require 'rubygems'
require 'sinatra'
set :bind, '127.0.0.1'
set :port, '4567'
post '/test' do
body "Hello"
status 202
return
end
请参阅下面发布的文件:
{
"caller":"TEST",
"c1": [ { "a" : ["b" ] } ],
"c2": [ { "a" : ["b" ] } ],
"c3": [ { "a" : ["b" ] } ],
"c4": [ { "a" : ["b" ] } ],
"c5": [ { "a" : ["b" ] } ],
"c6": [ { "a" : ["b" ] } ],
"c7": [ { "a" : ["b" ] } ],
"c8": [ { "a" : ["b" ] } ],
"c9": [ { "a" : ["b" ] } ],
"c10": [ { "a" : ["b" ] } ],
"c11": [ { "a" : ["b" ] } ],
"c12": [ { "a" : ["b" ] } ],
"c13": [ { "a" : ["b" ] } ],
"c14": [ { "a" : ["b" ] } ],
"c15": [ { "a" : ["b" ] } ],
"c16": [ { "a" : ["b" ] } ],
"c17": [ { "a" : ["b" ] } ],
"c18": [ { "a" : ["b" ] } ],
"c19": [ { "a" : ["b" ] } ],
"c20": [ { "a" : ["b" ] } ],
"c21": [ { "a" : ["b" ] } ],
"c22": [ { "a" : ["b" ] } ],
"c23": [ { "a" : ["b" ] } ],
"c24": [ { "a" : ["b" ] } ],
"c25": [ { "a" : ["b" ] } ]
}
请参阅下面用于发布我的文件的命令:
curl -v -H 'Accept: application/text' -X POST http://127.0.0.1:4567/test -d @$1
我认为问题是JSON结构。
我尝试在PHP服务器,Python和Java服务器中发布这个JSON,它可以工作。
数组数量的限制可能是由于Sinatra框架。 当我发布一个包含49个阵列的文件时,它可以正常工作,但是超过50个就会失败。
提前致谢。
答案 0 :(得分:0)
正如@Greg 提到的,为了解决这个问题,我只需要添加标题
-H 'Accept: application/json' -H 'Content-Type: application/json'
到查询