我使用XMLHttpRequest发送到服务器端创建的可恢复上传URL,将基于浏览器的可恢复上传到Google的云存储中.这在禁用Web安全性时完全正常,我在开发期间执行了此操作.
但现在在现实世界中,CORS一直在制造麻烦.我也尝试过与其他浏览器(没有成功),但坚持使用chrome进行进一步测试.
注意:fake.host条目/etc/HOSTS用于欺骗chrome以避免localhost限制.然而,我们的在线测试服务器的"真实"域也是如此.
使用普通的XMLHttpRequest调用启动请求:
var xhr = this.newXMLHttpRequest();
xhr.open('PUT', url, true);
xhr.setRequestHeader('Content-Type', this.currentInputFile.type);
xhr.setRequestHeader('Content-Range', 'bytes ' + startByte + '-' + (this.currentInputFile.size - 1) + '/' + this.currentInputFile.size);
xhr.onload = function(e) {
...
};
...
if (startByte > 0) {
xhr.send(this.currentInputFile.slice(startByte));
} else {
xhr.send(this.currentInputFile);
}
Run Code Online (Sandbox Code Playgroud)
然后浏览器成功启动预检请求:
Remote Address:173.194.71.95:443
Request URL:https://www.googleapis.com/upload/storage/v1/b/my-bucket-name/o?uploadType=resumable&name=aa%20spacetestSMALL_512kb.mp4&upload_id=XXXXXXXXX
Request Method:OPTIONS
Status Code:200 OK
Run Code Online (Sandbox Code Playgroud)
请求标题:
:host:www.googleapis.com
:method:OPTIONS
:path:/upload/storage/v1/b/my-bucket-name/o?uploadType=resumable&name=aa%20spacetestSMALL_512kb.mp4&upload_id=XXXXXXXXX
:scheme:https
:version:HTTP/1.1
accept:*/*
accept-encoding:gzip,deflate
accept-language:en-US,en;q=0.8,de;q=0.6
access-control-request-headers:content-range, content-type
access-control-request-method:PUT
origin:https://fake.host
referer:https://fake.host/upload.xhtml
user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X …Run Code Online (Sandbox Code Playgroud) https://javaserverfaces.java.net/nonav/2.2/releasenotes.html列出了JSF2.2的两个不同版本的分支,奇怪的是,2.2.8-xx似乎比2.2.9及更高版本更新.
一些错误仅在2.2.9(https://github.com/javaserverfaces/mojarra/issues/3384)中修复,有些只在2.2.8-xx 中修复(https://github.com/javaserverfaces/mojarra/issues/ 4111)和两个版本中的一些(https://github.com/javaserverfaces/mojarra/issues/3133).
这背后的原因是什么,我应该在生产中使用哪个分支?两者似乎都包含重要的错误修正.
我找不到谷歌的任何相关信息.也许mojarra家伙可以在发行说明中添加一些信息.
java 8 API doc SortedSet仅适用于stream()继承的状态java.util.Collection(请参阅https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html).这意味着流是顺序的,但可能不是有序的.
那么,确保sortedSet.stream().filter(...).findFirst()行为与for( ... )返回第一个匹配元素的经典循环相同的最安全方法是什么?或者情况已经如此,但不保证是API?
(findFirst()api doc:如果流没有遭遇顺序,则可以返回任何元素.)
Stream.sorted() 应该做的伎俩,但这增加了排序元素的开销,这些元素已经在原始集合中排序.