| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "nacl_io/httpfs/http_fs.h" | 5 #include "nacl_io/httpfs/http_fs.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <ctype.h> | 8 #include <ctype.h> |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 url_root_ += '/'; | 219 url_root_ += '/'; |
| 220 } | 220 } |
| 221 } else if (iter->first == "manifest") { | 221 } else if (iter->first == "manifest") { |
| 222 char* text; | 222 char* text; |
| 223 error = LoadManifest(iter->second, &text); | 223 error = LoadManifest(iter->second, &text); |
| 224 if (error) | 224 if (error) |
| 225 return error; | 225 return error; |
| 226 | 226 |
| 227 error = ParseManifest(text); | 227 error = ParseManifest(text); |
| 228 if (error) { | 228 if (error) { |
| 229 delete[] text; | 229 free(text); |
| 230 return error; | 230 return error; |
| 231 } | 231 } |
| 232 | 232 |
| 233 delete[] text; | 233 free(text); |
| 234 } else if (iter->first == "allow_cross_origin_requests") { | 234 } else if (iter->first == "allow_cross_origin_requests") { |
| 235 allow_cors_ = iter->second == "true"; | 235 allow_cors_ = iter->second == "true"; |
| 236 } else if (iter->first == "allow_credentials") { | 236 } else if (iter->first == "allow_credentials") { |
| 237 allow_credentials_ = iter->second == "true"; | 237 allow_credentials_ = iter->second == "true"; |
| 238 } else if (iter->first == "cache_stat") { | 238 } else if (iter->first == "cache_stat") { |
| 239 cache_stat_ = iter->second == "true"; | 239 cache_stat_ = iter->second == "true"; |
| 240 } else if (iter->first == "cache_content") { | 240 } else if (iter->first == "cache_content") { |
| 241 cache_content_ = iter->second == "true"; | 241 cache_content_ = iter->second == "true"; |
| 242 } else { | 242 } else { |
| 243 // Assume it is a header to pass to an HTTP request. | 243 // Assume it is a header to pass to an HTTP request. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 389 |
| 390 int error = Open(manifest_path, O_RDONLY, &manifest_node); | 390 int error = Open(manifest_path, O_RDONLY, &manifest_node); |
| 391 if (error) | 391 if (error) |
| 392 return error; | 392 return error; |
| 393 | 393 |
| 394 off_t size; | 394 off_t size; |
| 395 error = manifest_node->GetSize(&size); | 395 error = manifest_node->GetSize(&size); |
| 396 if (error) | 396 if (error) |
| 397 return error; | 397 return error; |
| 398 | 398 |
| 399 char* text = new char[size + 1]; | 399 char* text = (char*)malloc(size + 1); |
| 400 int len; | 400 int len; |
| 401 error = manifest_node->Read(HandleAttr(), text, size, &len); | 401 error = manifest_node->Read(HandleAttr(), text, size, &len); |
| 402 if (error) | 402 if (error) |
| 403 return error; | 403 return error; |
| 404 | 404 |
| 405 text[len] = 0; | 405 text[len] = 0; |
| 406 *out_manifest = text; | 406 *out_manifest = text; |
| 407 return 0; | 407 return 0; |
| 408 } | 408 } |
| 409 | 409 |
| 410 std::string HttpFs::MakeUrl(const Path& path) { | 410 std::string HttpFs::MakeUrl(const Path& path) { |
| 411 return url_root_ + | 411 return url_root_ + |
| 412 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join()); | 412 (path.IsAbsolute() ? path.Range(1, path.Size()) : path.Join()); |
| 413 } | 413 } |
| 414 | 414 |
| 415 } // namespace nacl_io | 415 } // namespace nacl_io |
| OLD | NEW |