summaryrefslogtreecommitdiffstats
path: root/google_apis/drive/request_util.cc
blob: cfaaa7da8c6c29cb01df2544e4ecd5f817b26fd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "google_apis/drive/request_util.h"

#include <string>
#include "base/values.h"

namespace google_apis {
namespace util {

namespace {

// etag matching header.
const char kIfMatchHeaderPrefix[] = "If-Match: ";
const char kParentLinkKind[] = "drive#fileLink";

}  // namespace

const char kIfMatchAllHeader[] = "If-Match: *";
const char kContentTypeApplicationJson[] = "application/json";

std::string GenerateIfMatchHeader(const std::string& etag) {
  return etag.empty() ? kIfMatchAllHeader : (kIfMatchHeaderPrefix + etag);
}

scoped_ptr<base::DictionaryValue> CreateParentValue(
    const std::string& file_id) {
  scoped_ptr<base::DictionaryValue> parent(new base::DictionaryValue);
  parent->SetString("kind", kParentLinkKind);
  parent->SetString("id", file_id);
  return parent;
}

}  // namespace util
}  // namespace google_apis