jjzjj

request-headers

全部标签

ruby-on-rails - Rails SSL 问题 : (https://example. com) 与 request.base_url (http ://example. com) 不匹配

我刚刚在我的网站上安装了SSL证书。不幸的是,它破坏了登录功能。在网站上提交登录表单后,它只是重定向到主页。检查Rails日志显示此错误:(https://example.com)didn'tmatchrequest.base_url(http://example.com)这是我的虚拟主机文件。我想我需要以某种方式强制使用SSL?ServerNameexample.comServerAliaswww.example.comRedirectpermanent/https://example.com/ServerAdminhello@example.comServerNameexample

ruby - 使用 Open::URI 显示 HTTP header ?

使用Open::URI,我可以执行以下操作:require'open-uri'#checkstatusopen('http://google.com').status#getentirehtmlopen('http://google.com').read是否可以获取请求的HTTPheader以便进行调试,例如Curls的curl-Ihttp://google.com?$curl-Igoogle.comHTTP/1.1301MovedPermanentlyLocation:http://www.google.com/Content-Type:text/html;charset=UTF-8

Ruby - 发送带有 header 的 GET 请求

我正在尝试将ruby​​与网站的api一起使用。说明是发送带有header的GET请求。这些是网站上的说明以及他们提供的示例php代码。我要计算HMAC哈希并将其包含在apisignheader下。$apikey='xxx';$apisecret='xxx';$nonce=time();$uri='https://bittrex.com/api/v1.1/market/getopenorders?apikey='.$apikey.'&nonce='.$nonce;$sign=hash_hmac('sha512',$uri,$apisecret);$ch=curl_init($uri);

ruby - 使用 Ruby CSV header 转换器

假设我有以下类(class):classBuyer以及CSV文件中的以下内容:FirstName,LastNameJohn,DoeJane,Doe我想将CSV的内容保存到数据库中。我在Rake文件中有以下内容:namespace:migrationdodesc"MigrateCSVdata"task:import,[:model,:file_path]=>:environmentdo|t,args|require'csv'model=args.model.constantizepath=args.file_pathCSV.foreach(path,:headers=>true,:con

ruby-on-rails - Ruby NET::HTTP 在主体之前读取 header (没有 HEAD 请求)?

我使用Net::HTTP和Ruby来抓取URL。我不想抓取流式音频,例如:http://listen2.openstream.co/334其实我只想抓取Html内容,所以没有pdfs、video、txt..现在,我将open_timeout和read_timeout都设置为10,所以即使我抓取这些流式音频页面,它们也会超时。url='http://listen2.openstream.co/334'path=uri.pathreq=Net::HTTP::Get.new(path,{'Accept'=>'*/*','Content-Type'=>'text/plain;charset=u

Ruby 1.9.3 - CSV.table 如何知道 CSV 文件中是否没有 header ?

我一直在用CSV.table做一些测试。我有两个几乎相同的小CSV文件,但其中一个缺少标题行。当我对带有标题行的CSV文件运行CSV.table时,一切都按预期进行。当我针对没有标题行的CSV文件运行它时,我得到:NoMethodError:undefinedmethod`encode'fornil:NilClass我用不同类型的数据、不同类型的header尝试了这个,并得到了相同的结果。我很好奇CSV.table的魔力。如果我使用CSV.parse并将标题设置为true,那么无论如何它总是使第一行成为标题。所以,我一直在使用CSV.table来检查导入的CSV文件是否有标题行,但我对

ruby-on-rails - 如何记录某个 url 的整个请求( header 、正文等)?

我需要将所有请求(包括HTTPheader、正文等)记录到某个url。我试过这段代码:defindexglobal_request_loggingendprivatedefglobal_request_logginghttp_request_header_keys=request.headers.keys.select{|header_name|header_name.match("^HTTP.*")}http_request_headers=request.headers.select{|header_name,header_value|http_request_header_key

ruby - 如何在使用 Ruby 的 OpenUri 下载之前获取 HTTP header

我目前正在使用OpenURI下载Ruby中的文件。不幸的是,如果不下载完整文件,似乎不可能获得HTTPheader:open(base_url,:content_length_proc=>lambda{|t|ift&&0t)end},:progress_proc=>lambda{|s|pbar.progress=sifpbar}){|io|putsio.sizeputsio.meta['content-disposition']}运行上面的代码表明它首先下载了完整的文件,然后才打印我需要的标题。有没有办法在下载完整文件之前获取header,以便在header与我预期的不同时取消下载?

ruby-on-rails - Hartl 教程中的 bundle exec rspec spec/requests/static_pages_spec.rb 不起作用

我正在按照MichaelHartl的ruby​​onrails教程测试示例应用程序(3.2.1测试驱动开发),但在键入bundleexecrspecspec/requests/static_pages_spec.rb后出现以下错误/home/rahul/.rvm/gems/ruby-2.0.0-p247@railstutorial_rails_4_0/gems/selenium-webdriver-2.0.0/lib/selenium/webdriver/common/zipper.rb:1:in`require':cannotloadsuchfile--zip/zip(LoadErr

ruby - 在 ruby​​ 中访问 Net::HTTP::Post 的 header

我有以下代码:uri=URI.parse("https://rs.xxx-travel.com/wbsapi/RequestListenerServlet")https=Net::HTTP.new(uri.host,uri.port)https.use_ssl=truereq=Net::HTTP::Post.new(uri.path)req.body=searchxmlreq["Accept-Encoding"]='gzip'res=https.request(req)这通常工作正常,但另一端的服务器提示我的XML中的某些内容,那里的技术人员需要xml消息和正在发送的header。我收