草庐IT

ERR_HTTP_RESPONSE_CODE_FAILURE

全部标签

ruby - 使用 TCPServer 的 Ruby 中的简单 HTTP 服务器

为了一项学校作业,我尝试使用Ruby和套接字库创建一个简单的HTTP服务器。现在,我可以让它通过一个简单的问候来响应任何连接:require'socket'server=TCPServer.open2000puts"Listeningonport2000"loop{client=server.accept()resp="Hello?"headers=["HTTP/1.1200OK","Date:Tue,14Dec201010:48:45GMT","Server:Ruby","Content-Type:text/html;charset=iso-8859-1","Content-Leng

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:阻止 HTTP.new.start 和动态 HTTP(S)

我需要一个应用程序来阻止HTTP请求,所以我不得不添加几行代码,唯一我想不通的是语句ifuri.scheme=='https';http.use_ssl=true有没有办法在当前语句中设置http/https:Net::HTTP.new(uri.host,uri.port).startdo|http|#CausesandIOError...ifuri.scheme=='https'http.use_ssl=trueendrequest=Net::HTTP::Get.new(uri.request_uri)http.request(request)end添加:IOError:use_ss

ruby - 从字符串中删除 "http://"和 "https://"

我是ruby新手使用正则表达式。如何从字符串中删除https和http以及wwwserver=http://france24.miles.comserver=https://seloger.com我想从这些站点中删除所有http、https和wwwfrance24.miles.comseloger.com我使用了下面的代码,但它不适合我server=server.(/^https?\:\/\/(www.)?/,'') 最佳答案 server=server.(/^https?\:\/\/(www.)?/,'')这没有用,因为您没有调用

ruby-on-rails - 为自定义 omniauth 策略获取 "Authentication failure! invalid_credentials: OAuth2::Error"

目前我正在处理Rails4项目,现在我必须链接/连接另一个应用程序(不是sso,而是用于访问API),比如example.com。(注意example.com使用三足式oauth安全架构)搜索后发现必须要实现omniouth策略。为此我引用了this关联。根据Strategy-Contribution-Guide我能够完成设置和请求阶段,您可以在此处找到我的示例代码。require'multi_json'require'omniauth/strategies/oauth2'require'uri'moduleOmniAuthmoduleStrategiesclassMyAppStrat

Ruby 1.8.7 和 Net::HTTP:使用客户端证书发出 SSL GET 请求?

我正在尝试使用Net::HTTP通过SSL获取资源。这是相关的代码片段:req=Net::HTTP::Get.new(ContentURI.path)https=Net::HTTP.new(ContentURI.host,ContentURI.port)https.use_ssl=truehttps.cert=OpenSSL::X509::Certificate.new(@cert_raw)https.key=OpenSSL::PKey::RSA.new(@cert_key_raw)https.verify_mode=OpenSSL::SSL::VERIFY_PEERhttps.ca_

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

Spring 国际化遇到的坑 No message found under code ‘xxx.xxxx‘ for locale ‘zh_CN‘

Spring国际化遇到的坑org.springframework.context.NoSuchMessageException:Nomessagefoundundercode‘xxx.xxxx’forlocale‘zh_CN’背景以前做的项目客户群体只有国内的客户,从来没有考虑过语言文字的问题。这次有一个需求的返回内容,要根据客户设置的语言返回不同的语言。尝试使用了以后,结果发现怎么都不好使,一直报的一个错误如下:org.springframework.context.NoSuchMessageException:Nomessagefoundundercode'user.name'forloc

ruby - `open_http' : 403 Forbidden (OpenURI::HTTPError) 字符串 "Steve_Jobs"但不是任何其他字符串

我正在学习http://ruby.bastardsbook.com/提供的Ruby教程我遇到了以下代码:require"open-uri"remote_base_url="http://en.wikipedia.org/wiki"r1="Steve_Wozniak"r2="Steve_Jobs"f1="my_copy_of-"+r1+".html"f2="my_copy_of-"+r2+".html"#readthefirsturlremote_full_url=remote_base_url+"/"+r1rpage=open(remote_full_url).read#writeth

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与我预期的不同时取消下载?