我不确定这是什么,但当我这样做时:
curl -X POST -d '{"foo":"bar"}'
-H 'Content-Type: application/json'
-H 'Authorization: Token bdcaf10129ba8ad968c03c6083898bf8c426f749d4e9a14d58e4ef02bfe1c217'
'http://api.site.local.com:4000/internal/application/v1/users'
# New lines in above request are only there for readability.
curl: (7) Failed to connect to api.site.local.com port 4000: Connection refused
但是如果我去:
http://api.site.local.com:4000/internal/application/v1/users
它有效,我的意思是我得到一个错误,没有索引动作,但实际路线存在且工作正常。
那么为什么浏览器会说“是”,但是curl说“不”?
我的意思是我的测试:
it "should return 200 for a user being published" do
VCR.use_cassette 'publisher/publish_user_200' do
site = double(
'site',
:site_api_url => YAML.load(File.read('config/application.yml'))['APPLICATION_URL'].to_s,
:site_api_key => YAML.load(File.read('config/application.yml'))['APPLICATION_KEY'].to_s
)
expect(
BlackBird::PublishToSites::User.publish(
site,
{
first_name: 'adsadsad', user_name: 'sasdasdasdsa' ,
email: 'asdassad@sample.com', auth_token: 'asdsadasdasdsa'
}
).code
).to eql 200
end
返回0,表示无法连接。我做错了什么我不知道吗?
注意: applications.yml文件中的应用程序密钥和url与curl请求中的值相同。