我已经安装了Prerenderer IO在我的 Mac 机器 (OS X Yosemite 10.10.3) 上。安装完成后,我运行 sudo npm install 并运行 sudo node server.js 得到以下错误:
phantom stdout: XMLHttpRequest cannot load http://::1:12302/dnode/info. Cross origin requests are only supported for HTTP.
phantom stdout: XMLHttpRequest cannot load http://::1:12301/dnode/info. Cross origin requests are only supported for HTTP.
phantom stdout: NETWORK_ERR: XMLHttpRequest Exception 101: A network error occured in synchronous requests.
.../node_modules/phantom/shim.js:1815
.../node_modules/phantom/shim.js:1842
phantom stdout: NETWORK_ERR: XMLHttpRequest Exception 101: A network error occured in synchronous requests.
.../node_modules/phantom/shim.js:1815
.../node_modules/phantom/shim.js:1842
2015-08-04T13:45:47.307Z getting https://google.com
phantom stdout: XMLHttpRequest cannot load http://::1:12303/dnode/info. Cross origin requests are only supported for HTTP.
NETWORK_ERR: XMLHttpRequest Exception 101: A network error occured in synchronous requests.
.../node_modules/phantom/shim.js:1815
.../node_modules/phantom/shim.js:1842
phantom stdout: XMLHttpRequest cannot load http://::1:12304/dnode/info. Cross origin requests are only supported for HTTP.
phantom stdout: NETWORK_ERR: XMLHttpRequest Exception 101: A network error occured in synchronous requests.
.../node_modules/phantom/shim.js:1815
.../node_modules/phantom/shim.js:1842
我尝试输入一个 url http://localhost:3000/https://google.com,几分钟后它挂断了。
我已经更改了权限并尝试全局安装。两者都不行
最佳答案
我遇到了同样的问题,并在第 70 行更改了此文件 lib/server.js,如下所示:
var args = ["--load-images=false", "--ignore-ssl-errors=true", "--ssl-protocol=tlsv1"];
对此:
var args = ["--load-images=false", "--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", "--web-security=no "];
现在您的 NETWORK_ERROR 应该消失了。
查看此 stack或者 tihs github issue了解更多信息。
关于javascript - Prerenderer IO:XMLHttpRequest 无法加载 http://::1:12301/dnode/info 和 NETWORK_ERR:XMLHttpRequest 异常 101:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31815405/
是的,我知道最好使用webmock,但我想知道如何在RSpec中模拟此方法:defmethod_to_testurl=URI.parseurireq=Net::HTTP::Post.newurl.pathres=Net::HTTP.start(url.host,url.port)do|http|http.requestreq,foo:1endresend这是RSpec:let(:uri){'http://example.com'}specify'HTTPcall'dohttp=mock:httpNet::HTTP.stub!(:start).and_yieldhttphttp.shou
我目前正在使用以下方法获取页面的源代码:Net::HTTP.get(URI.parse(page.url))我还想获取HTTP状态,而无需发出第二个请求。有没有办法用另一种方法做到这一点?我一直在查看文档,但似乎找不到我要找的东西。 最佳答案 在我看来,除非您需要一些真正的低级访问或控制,否则最好使用Ruby的内置Open::URI模块:require'open-uri'io=open('http://www.example.org/')#=>#body=io.read[0,50]#=>"["200","OK"]io.base_ur
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
Rails中有没有一种方法可以提取与路由关联的HTTP动词?例如,给定这样的路线:将“users”匹配到:“users#show”,通过:[:get,:post]我能实现这样的目标吗?users_path.respond_to?(:get)(显然#respond_to不是正确的方法)我最接近的是通过执行以下操作,但它似乎并不令人满意。Rails.application.routes.routes.named_routes["users"].constraints[:request_method]#=>/^GET$/对于上下文,我有一个设置cookie然后执行redirect_to:ba
我正在使用Heroku(heroku.com)来部署我的Rails应用程序,并且正在构建一个iPhone客户端来与之交互。我的目的是将手机的唯一设备标识符作为HTTPheader传递给应用程序以进行身份验证。当我在本地测试时,我的header通过得很好,但在Heroku上它似乎去掉了我的自定义header。我用ruby脚本验证:url=URI.parse('http://#{myapp}.heroku.com/')#url=URI.parse('http://localhost:3000/')req=Net::HTTP::Post.new(url.path)#boguspara
-if!request.path_info.include?'A'%{:id=>'A'}"Text"-else"Text"“文本”写了两次。我怎样才能只写一次并同时检查path_info是否包含“A”? 最佳答案 有两种方法可以做到这一点。使用部分,或使用content_forblock:如果“文本”较长,或者是一个重要的子树,您可以将其提取到一个部分。这会使您的代码变干一点。在给出的示例中,这似乎有点矫枉过正。在这种情况下更好的方法是使用content_forblock,如下所示:-if!request.path_info.inc
我试图在我的网站上实现使用Facebook登录功能,但在尝试从Facebook取回访问token时遇到障碍。这是我的代码:ifparams[:error_reason]=="user_denied"thenflash[:error]="TologinwithFacebook,youmustclick'Allow'toletthesiteaccessyourinformation"redirect_to:loginelsifparams[:code]thentoken_uri=URI.parse("https://graph.facebook.com/oauth/access_token
我遇到了一个非常奇怪的问题,我很难解决。在我看来,我有一个与data-remote="true"和data-method="delete"的链接。当我单击该链接时,我可以看到对我的Rails服务器的DELETE请求。返回的JS代码会更改此链接的属性,其中包括href和data-method。再次单击此链接后,我的服务器收到了对新href的请求,但使用的是旧的data-method,即使我已将其从DELETE到POST(它仍然发送一个DELETE请求)。但是,如果我刷新页面,HTML与"new"HTML相同(随返回的JS发生变化),但它实际上发送了正确的请求类型。这就是这个问题令我困惑的
我是Ruby的新手。我试过查看在线文档,但没有找到任何有效的方法。我想在以下HTTP请求botget_response()和get()中包含一个用户代理。有人可以指出我正确的方向吗?#PreliminarycheckthatProggitisupcheck=Net::HTTP.get_response(URI.parse(proggit_url))ifcheck.code!="200"puts"ErrorcontactingProggit"returnend#Attempttogetthejsonresponse=Net::HTTP.get(URI.parse(proggit_url)
我正在尝试解析网页,但有时会收到404错误。这是我用来获取网页的代码:result=Net::HTTP::getURI.parse(URI.escape(url))如何测试result是否为404错误代码? 最佳答案 像这样重写你的代码:uri=URI.parse(url)result=Net::HTTP.start(uri.host,uri.port){|http|http.get(uri.path)}putsresult.codeputsresult.body这将打印状态码和正文。