feat: Respect the file mode for HttpFiles (#1081)

For a read mode, make a GET request.  Otherwise, make a PUT request.
This commit is contained in:
Joey Parrish 2022-08-17 10:40:13 -07:00 committed by GitHub
parent 868208198a
commit 31e116faec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -106,13 +106,19 @@ File* CreateUdpFile(const char* file_name, const char* mode) {
}
File* CreateHttpsFile(const char* file_name, const char* mode) {
UNUSED(mode); // TODO: choose method based on file mode
return new HttpFile(HttpMethod::kPut, std::string("https://") + file_name);
HttpMethod method = HttpMethod::kGet;
if (strcmp(mode, "r") != 0) {
method = HttpMethod::kPut;
}
return new HttpFile(method, std::string("https://") + file_name);
}
File* CreateHttpFile(const char* file_name, const char* mode) {
UNUSED(mode); // TODO: choose method based on file mode
return new HttpFile(HttpMethod::kPut, std::string("http://") + file_name);
HttpMethod method = HttpMethod::kGet;
if (strcmp(mode, "r") != 0) {
method = HttpMethod::kPut;
}
return new HttpFile(method, std::string("http://") + file_name);
}
File* CreateMemoryFile(const char* file_name, const char* mode) {