我们正在制作一个OSX版本的Windows应用程序,它严重依赖于We视图和一些javascript。
在Windows中,基本流程如下:
在窗户上,这个很好用。在我们的OSX应用程序上,我们可以进入第6步。在这一点上,由于某些原因我们无法弄清楚,请求类型正在被更改。虽然它应该是一个帖子,但它却以GET的形式出现。路由服务器在此时返回一个错误,因为它期望得到POST (以及相应的POST数据)。
由于此问题不发生在windows或我们的浏览器中,那么Safari或OSX是否有可能劫持POST请求?也许需要在打开/关闭我们错过的选项的情况下创建webview。我们已经搜索过,但没有发现任何东西,因此,如果有人有任何见解,这将是非常感谢的。
员额请求示例:
{
"apptype": "Win",
"calltype": "CC",
"localTimestamp": "2014-12-10T22:37:35.499Z",
"timezone": 7,
"test": false,
"version": "1.0",
"deviceID": "Parallels-1A B0 48 1A 9F DE 43 4E 9D 99 D7 B3 10 69 4F 84",
"machineID": "19b1bde9fd7ee2efc5d15bad37101229e9d3bc11d9ac9500bffc04c0e4e638fe",
"model": "Parallels Virtual Platform",
"userID": "739e94e70db1ed4372a8744f52dd5f3d",
"country": "US",
"language": "en-US",
"contentID": "",
"prod": "DEM1",
"platformversion": "6.3.9600",
"options": {
"programArguments": {
"contentURL": "http://www.google.com"
},
"launchSource": "manual",
"visible": true
}
}答复示例:
{
"messageID": "1",
"instructioncode": "displayContent",
"contentID": "5",
"date": "2014-12-10 15:37:36",
"sessionID": "",
"expirationdate": "2199-12-31 23:59:59",
"contentURL": "http://www.google2.com",
"options": {
"remindMinutes": "4320"
}
}发布于 2015-10-14 22:14:47
在我想出这个问题之后,我从来没有回答过这个问题,所以我的答案是:
webview是用以下内容创建的
- (NSURLRequest *)webView:(WebView *)sender
resource:(id)identifier
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *)redirectResponse
fromDataSource:(WebDataSource *)dataSource
{
// Replace the request with one that ignores the cache
request = [NSURLRequest requestWithURL:[request URL]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:[request timeoutInterval]];
return request;
}其目的是确保webview从未被缓存。它成功了!但它也劫持了每个请求,并将帖子变成了GET。解决方案只是注释掉它,在服务器端处理缓存内容,而不是在应用程序中。
- (NSURLRequest *)webView:(WebView *)sender
resource:(id)identifier
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *)redirectResponse
fromDataSource:(WebDataSource *)dataSource
{
// Replace the request with one that ignores the cache
//request = [NSURLRequest requestWithURL:[request URL]
//cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
//timeoutInterval:[request timeoutInterval]];
return request;
}https://stackoverflow.com/questions/28619423
复制相似问题