Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/nacl_sdk/pepper_canary/src/nacl_io/httpfs/http_fs.cc
- +++ b/nacl_sdk/pepper_canary/src/nacl_io/httpfs/http_fs.cc
- @@ -213,9 +213,11 @@ Error HttpFs::Init(const FsInitArgs& args) {
- ++iter) {
- if (iter->first == "SOURCE") {
- url_root_ = iter->second;
- + is_blob_url_ = url_root_.substr(0,5) == "blob:";
- // Make sure url_root_ ends with a slash.
- - if (!url_root_.empty() && url_root_[url_root_.length() - 1] != '/') {
- + // Blob URLs must not get a slash appended.
- + if (!url_root_.empty() && !is_blob_url_ && url_root_[url_root_.length() - 1] != '/') {
- url_root_ += '/';
- }
- } else if (iter->first == "manifest") {
- --- a/nacl_sdk/pepper_canary/src/nacl_io/httpfs/http_fs_node.cc
- +++ b/nacl_sdk/pepper_canary/src/nacl_io/httpfs/http_fs_node.cc
- @@ -234,18 +236,36 @@ Error HttpFsNode::GetStat_Locked(struct stat* stat) {
- ScopedResource response(filesystem_->ppapi());
- int32_t statuscode;
- StringMap_t response_headers;
- - Error error = OpenUrl("HEAD",
- - &headers,
- - &loader,
- - &request,
- - &response,
- - &statuscode,
- - &response_headers);
- + Error error(0);
- +
- + // TODO: data URLs
- + if (filesystem->is_blob_url_) {
- + // Blob URLs do not support HEAD requests, but do give the content length
- + // in their response headers. We issue a single-byte GET request to retrieve
- + // the content length.
- + headers["Range"] = "bytes=0-0";
- + error = OpenUrl("GET",
- + &headers,
- + &loader,
- + &request,
- + &response,
- + &statuscode,
- + &response_headers);
- + } else {
- + error = OpenUrl("HEAD",
- + &headers,
- + &loader,
- + &request,
- + &response,
- + &statuscode,
- + &response_headers);
- + }
- +
- if (error)
- return error;
- - size_t entity_length;
- - if (ParseContentLength(response_headers, &entity_length)) {
- + size_t read_start, read_end, entity_length;
- + if ((filesystem->is_blob_url_ && ParseContentRange(response_headers, &read_start, &read_end, &entity_length)) || (!filesystem->is_blob_url_ && ParseContentLength(response_headers, &entity_length))) {
- SetCachedSize(static_cast<off_t>(entity_length));
- } else if (cache_content_) {
- // The server didn't give a content length; download the data to memory
- --- a/nacl_sdk/pepper_canary/include/nacl_io/httpfs/http_fs.h
- +++ b/nacl_sdk/pepper_canary/include/nacl_io/httpfs/http_fs.h
- @@ -53,6 +53,7 @@ class HttpFs : public Filesystem {
- bool allow_credentials_;
- bool cache_stat_;
- bool cache_content_;
- + bool is_blob_url_;
- friend class TypedFsFactory<HttpFs>;
- friend class HttpFsNode;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement