如何在服务器端使用easyXDM获取User-Agent
我尝试使用此 Eaxmple 但它没有将 User-Agent 传递到服务器
client.html
rpc:new easyXDM.Rpc({
remote: remoteXDM // the path to the provider
},
{
remote: {
login:{}
}
}),
Sendrequesttoserver: function(message){
tricklebot.rpc.login(message,function(response){
alert(response);
},
function(response) {
alert("Error message : "+response.message);
});
}
服务器端 api.html caode
var rpc = new easyXDM.Rpc({},
{
local: {
login: function(message, successFn, errorFn){
serverresponce(message,successFn,errorFn);
}
}
});
serverresponce(message,successFn,errorFn){
Ext.Ajax.request({
url: urlhost+'/welcome',
method: 'POST',
jsonData: '{\"message\":\"'+message+'\"}',
success: function(response, opt) {
successFn(response);
},
failure: function(response, action) {
errorFn("invalid message");
}
});
}
在欢迎页面 url 上
request.getHeader("User-Agent");
它在欢迎页面上给出 null
我能够接收消息但无法接收 request.getHeader("User -代理人”);
那么如何在服务器端使用 easyXDM 从请求获取用户代理
i try with this Eaxmple but it not pass User-Agent to the server
client.html
rpc:new easyXDM.Rpc({
remote: remoteXDM // the path to the provider
},
{
remote: {
login:{}
}
}),
Sendrequesttoserver: function(message){
tricklebot.rpc.login(message,function(response){
alert(response);
},
function(response) {
alert("Error message : "+response.message);
});
}
server side api.html caode
var rpc = new easyXDM.Rpc({},
{
local: {
login: function(message, successFn, errorFn){
serverresponce(message,successFn,errorFn);
}
}
});
serverresponce(message,successFn,errorFn){
Ext.Ajax.request({
url: urlhost+'/welcome',
method: 'POST',
jsonData: '{\"message\":\"'+message+'\"}',
success: function(response, opt) {
successFn(response);
},
failure: function(response, action) {
errorFn("invalid message");
}
});
}
on welcome page url
request.getHeader("User-Agent");
its give null
on welcome page i able to reciver message but not able to recive request.getHeader("User-Agent");
so how to get User-Agent using easyXDM at server side from Request
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将用户代理注入到请求中(这样您就可以在终点收到它):
navigator.userAgent
You can inject the user agent into the request (so you would then receive it at the end point):
navigator.userAgent