checkpoint

git-svn-id: http://s3fs.googlecode.com/svn/trunk@23 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
rrizun 2007-12-05 00:48:05 +00:00
parent 008b87f6d8
commit 7e7eec113d
1 changed files with 36 additions and 1 deletions

View File

@ -182,7 +182,7 @@ calc_signature(string method, string content_type, string date, curl_slist* head
if (strncmp(headers->data, "x-amz", 5) == 0) {
++count;
StringToSign += headers->data;
StringToSign += 10;
StringToSign += 10; // linefeed
}
} while ((headers = headers->next) != 0);
}
@ -212,6 +212,7 @@ calc_signature(string method, string content_type, string date, curl_slist* head
return Signature;
}
string
calc_signature(string method, string content_type, string date, string resource) {
return calc_signature(method, content_type, date, 0, resource);
@ -235,6 +236,37 @@ writeCallback(void* data, size_t blockSize, size_t numBlocks, void* userPtr) {
return blockSize*numBlocks;
}
// ### TODO replace this w/curl_easy_getopt
static size_t headerCallback(void *data,
size_t blockSize,
size_t numBlocks,
void *userPtr) {
struct stat* stbuf = reinterpret_cast<struct stat*>(userPtr);
string header(reinterpret_cast<char *>(data), blockSize*numBlocks);
cout << "header: " << header << endl;
// stringstream ss(header);
// string key;
// ss >> key;
//// if (key == "Last-Modified:") {
//// string LastModified;
//// ss >> LastModified;
////
//// cout << ">>>>>" << ss.str() << endl;
//// //time_t t = curl_getdate(LastModified.c_str(), 0);
//// stbuf->st_mtime = curl_getdate(LastModified.c_str(), 0);
//// }
// if (key == "Content-Type:") {
// string ContentType;
// ss >> ContentType;
// stbuf->st_mode = S_IFREG | 0755;
// if (ContentType == "application/x-directory")
// stbuf->st_mode = S_IFDIR | 0755;
// }
// if (key == "Content-Length:")
// ss >> stbuf->st_size;
return blockSize*numBlocks;
}
static int
s3fs_getattr(const char *path, struct stat *stbuf) {
memset(stbuf, 0, sizeof(struct stat));
@ -264,6 +296,9 @@ s3fs_getattr(const char *path, struct stat *stbuf) {
curl_easy_setopt(curl, CURLOPT_NOBODY, true); // HEAD
curl_easy_setopt(curl, CURLOPT_FILETIME, true); // Last-Modified
curl_easy_setopt(curl, CURLOPT_HEADERDATA, stbuf);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, headerCallback);
auto_curl_slist headers;
string date = get_date();
headers.append("Date: "+date);