~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/rgw/rgw_common.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-08-27 08:23:21 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120827082321-2cfej6ddvk63vsqq
Tags: upstream-0.48.1
ImportĀ upstreamĀ versionĀ 0.48.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
  return true;
137
137
}
138
138
 
 
139
static bool check_gmt_end(const char *s)
 
140
{
 
141
  if (!s || !*s)
 
142
    return false;
 
143
 
 
144
  while (isspace(*s)) {
 
145
    ++s;
 
146
  }
 
147
 
 
148
  /* check for correct timezone */
 
149
  if ((strncmp(s, "GMT", 3) != 0) &&
 
150
      (strncmp(s, "UTC", 3) != 0)) {
 
151
    return false;
 
152
  }
 
153
 
 
154
  /* trailing space */
 
155
  s += 3;
 
156
  while (isspace(*s)) {
 
157
    ++s;
 
158
  }
 
159
  if (*s)
 
160
    return false;
 
161
 
 
162
  return true;
 
163
}
 
164
 
139
165
static bool parse_rfc850(const char *s, struct tm *t)
140
166
{
141
167
  memset(t, 0, sizeof(*t));
142
 
  return check_str_end(strptime(s, "%A, %d-%b-%y %H:%M:%S GMT", t));
 
168
  return check_gmt_end(strptime(s, "%A, %d-%b-%y %H:%M:%S ", t));
143
169
}
144
170
 
145
171
static bool parse_asctime(const char *s, struct tm *t)
151
177
static bool parse_rfc1123(const char *s, struct tm *t)
152
178
{
153
179
  memset(t, 0, sizeof(*t));
154
 
  return check_str_end(strptime(s, "%a, %d %b %Y %H:%M:%S GMT", t));
 
180
  return check_gmt_end(strptime(s, "%a, %d %b %Y %H:%M:%S ", t));
155
181
}
156
182
 
157
183
static bool parse_rfc1123_alt(const char *s, struct tm *t)
294
320
    NameVal nv(nameval);
295
321
    int ret = nv.parse();
296
322
    if (ret >= 0) {
297
 
      val_map[nv.get_name()] = nv.get_val();
 
323
      string& name = nv.get_name();
 
324
      string& val = nv.get_val();
 
325
      val_map[name] = val;
298
326
 
299
 
      if ((nv.get_name().compare("acl") == 0) ||
300
 
          (nv.get_name().compare("location") == 0) ||
301
 
          (nv.get_name().compare("uploads") == 0) ||
302
 
          (nv.get_name().compare("partNumber") == 0) ||
303
 
          (nv.get_name().compare("uploadId") == 0) ||
304
 
          (nv.get_name().compare("versionid") == 0) ||
305
 
          (nv.get_name().compare("torrent") == 0)) {
306
 
        sub_resources[nv.get_name()] = nv.get_val();
 
327
      if ((name.compare("acl") == 0) ||
 
328
          (name.compare("location") == 0) ||
 
329
          (name.compare("uploads") == 0) ||
 
330
          (name.compare("partNumber") == 0) ||
 
331
          (name.compare("uploadId") == 0) ||
 
332
          (name.compare("versionId") == 0) ||
 
333
          (name.compare("torrent") == 0)) {
 
334
        sub_resources[name] = val;
 
335
      } else if (name[0] == 'r') { // root of all evil
 
336
        if ((name.compare("response-content-type") == 0) ||
 
337
           (name.compare("response-content-language") == 0) ||
 
338
           (name.compare("response-expires") == 0) ||
 
339
           (name.compare("response-cache-control") == 0) ||
 
340
           (name.compare("response-content-disposition") == 0) ||
 
341
           (name.compare("response-content-encoding") == 0)) {
 
342
          sub_resources[name] = val;
 
343
          has_resp_modifier = true;
 
344
        }
307
345
      }
308
346
    }
309
347
 
313
351
  return 0;
314
352
}
315
353
 
316
 
string& XMLArgs::get(string& name)
 
354
string& XMLArgs::get(string& name, bool *exists)
317
355
{
318
356
  map<string, string>::iterator iter;
319
357
  iter = val_map.find(name);
320
 
  if (iter == val_map.end())
321
 
    return empty_str;
322
 
  return iter->second;
 
358
  bool e = (iter != val_map.end());
 
359
  if (exists)
 
360
    *exists = e;
 
361
  if (e)
 
362
    return iter->second;
 
363
  return empty_str;
323
364
}
324
365
 
325
 
string& XMLArgs::get(const char *name)
 
366
string& XMLArgs::get(const char *name, bool *exists)
326
367
{
327
368
  string s(name);
328
 
  return get(s);
 
369
  return get(s, exists);
329
370
}
330
371
 
331
372
bool verify_bucket_permission(struct req_state *s, int perm)