草庐IT

javascript - PassportJS 回调在 http 和 https 之间切换

全部标签

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 - 使用 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 - 如何在命令行上切换 cocoapods(或其他 gem)版本?

有一些答案说使用gem'cocoapods','0.33.1'或gem'pod','0.33.1但这行不通。错误:执行gem时...(Gem::CommandLineError)未知命令cocoapods,在一个项目中我需要使用0.33.1,但在另一个项目中需要使用0.34.4。如何在命令行快速切换cocoapods版本?我不想使用gem安装或卸载。我将rbenv与ruby​​版本2.0.0p0一起使用。继续使用rbenv是首选,但只有在没有其他选择的情况下,我才能切换到rvm或纯ruby​​。谢谢。 最佳答案 您可以执行以下操作以

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 - Thread#run 和 Thread#wakeup 之间的区别?

在Ruby中,Thread#run和Thread#wakup有什么区别?RDoc指定scheduler不使用Thread#wakeup调用,但这是什么意思?何时使用唤醒与运行的示例?谢谢。编辑:我看到Thread#wakup导致线程变为可运行状态,但如果在执行Thread#run之前它不会执行(无论如何都会唤醒线程),它有什么用?有人可以提供一个示例,其中wakeup做了一些有意义的事情吗?出于好奇=) 最佳答案 这里有一个例子来说明它的含义(来自here的代码示例):线程唤醒thread=Thread.newdoThread.st

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 元编程向 Rails 模型添加回调?

我写了一个简单的Cacheable模块,它使得在父模型中缓存聚合字段变得简单。该模块要求父对象为需要在父级缓存的每个字段实现cacheable方法和calc_方法。moduleCacheabledefcache!(fields,*objects)objects.eachdo|object|ifobject.cacheable?calc(fields,objects)save!(objects)endendenddefcalc(fields,objects)fields.each{|field|objects.each(&:"calc_#{field}")}enddefsave!(obj

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