草庐IT

http-accept-header

全部标签

ruby-on-rails - accepts_nested_attributes_for rails 4 没有删除

我已经阅读和研究了大约3天。这是我最后的选择。土地.rb:has_many:uploads,:dependent=>:destroyaccepts_nested_attributes_for:uploads,:allow_destroy=>true,:reject_if=>:all_blank上传.rbbelongs_to:land_land_form_partial.html.erb{:multipart=>true}do|f|%>Delete:#...buttonsandotherfieldslands_controller.rbdefupdateif@land.update_at

Ruby Net::HTTP - 遵循 301 重定向

我的用户提交url(到mixcloud.com上的mixes),我的应用使用它们来执行网络请求。好的url返回200状态代码:uri=URI.parse("http://www.mixcloud.com/ErolAlkan/hard-summer-mix/")request=Net::HTTP.get_response(uri)(#但是,如果您忘记了结尾的斜杠,那么我们的否则很好url将返回301:uri="http://www.mixcloud.com/ErolAlkan/hard-summer-mix"#404也会发生同样的事情:#badpathreturnsa404"http:/

ruby-on-rails - 如何从 Ruby on Rails 应用程序返回正确的 HTTP 错误代码

我有RoR3.0网络应用程序,它充当OAuthAPI提供程序。现在,在API中,我想向API使用者返回正确的HTTP错误代码。我该怎么做?例子如下:defdestroy_oauth@item=Item.find(params[:id])if(!@item.nil?&&@item.user_id==current_user.id)@item.destroyrespond_todo|format|format.jsformat.xmlendelseraiseActionController::RoutingError.new('Forbidden')endend因此,如果出现错误,我会尝试

带 header 的 Ruby https POST

如何使用json在Ruby中创建带有header的Https帖子?我试过:uri=URI.parse("https://...")https=Net::HTTP.new(uri.host,uri.port)req=Net::HTTP::Post.new(uri.path)req['foo']=barres=https.request(req)putsres.body 最佳答案 问题是json。这解决了我的问题。无论如何,我的问题不清楚,所以赏金给了Jurirequire'uri'require'net/http'require'ne

ruby-on-rails - ruby中的异步http请求

require'net/http'urls=[{'link'=>'http://www.google.com/'},{'link'=>'http://www.facebook.com/'},{'link'=>'http://www.yahoo.com/'}]urls.eachdo|u|u['content']=Net::HTTP.get(URI.parse(u['link']))endprinturls这将作为程序代码工作。我只想访问服务器,没有关于顺序的问题。我怎么能在ruby中做到这一点。一种选择是使用线程。这是一个使用线程的例子。require'net/http'urls=[{'

ruby - 在 Ruby 中设置请求 header

我有其余的客户端gem,我正在定义这样的请求:url='http://someurl'request={"data"=>data}.to_jsonresponse=RestClient.post(url,request,:content_type=>:json,:accept=>:json)但是我需要将HTTPheader设置为某些内容。例如APIkey。这可以在curl中完成:curl-XHEAD-Hx-auth-user:myusername-Hx-auth-key:mykey"url"在ruby​​中执行此操作的最佳方法是什么?使用这个gem?或者我可以手动执行此操作以获得更多控

ruby-on-rails - Rails 应用程序:Solr 抛出 RSolr::Error::Http - 执行搜索时未找到 404

非常迷茫,因为我没有对我的搜索进行任何更改,该搜索一直有效,但不知何故我休息了。作为Rails的新手,错误输出没有给我足够的细节来进行调试。下面的相关代码-询问您是否还想查看其他内容。home.html.slim(带有搜索表单的摘录)=form_tagsearch_venues_path,method::get,id:'search'do|f|.search-fields.span16p=text_field_tag:q,'',placeholder:"Searchforcoffee,hotel,etc",class:'span7search-field'p=text_field_ta

ruby - 如何在 OpenURI 中指定 "http request header"

我正在尝试使用Ruby的OpenURIgem调用URL,但是它需要我在其HTTP请求header中传递某些值。知道怎么做吗? 最佳答案 根据thedocumentation,您可以将httpheader的哈希值作为第二个参数传递给open:open("http://www.ruby-lang.org/en/","User-Agent"=>"Ruby/#{RUBY_VERSION}","From"=>"foo@bar.invalid","Referer"=>"http://www.ruby-lang.org/"){|f|#...}

ruby - Rack::Request - 如何获取所有 header ?

标题是不言自明的。有什么方法可以获取header(Rack::Request.env[]除外)? 最佳答案 HTTPheader在Rackenvironment中可用。传递给您的应用:HTTP_Variables:Variablescorrespondingtotheclient-suppliedHTTPrequestheaders(i.e.,variableswhosenamesbeginwithHTTP_).Thepresenceorabsenceofthesevariablesshouldcorrespondwiththepr

ruby - 如何在 ruby​​ 中通过 SSL 调用 HTTP POST 方法?

所以这是使用curl的请求:curl-XPOST-Hcontent-type:application/json-d"{\"credentials\":{\"username\":\"username\",\"key\":\"key\"}}"https://auth.api.rackspacecloud.com/v1.1/auth我一直在尝试使用ruby​​发出同样的请求,但我似乎无法让它工作。我也尝试了几个库,但我无法让它工作。这是我到目前为止所拥有的:uri=URI.parse("https://auth.api.rackspacecloud.com")http=Net::HTTP.