]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't crash if HTTP_HOST isn't set
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 13 Apr 2010 22:47:31 +0000 (15:47 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Tue, 13 Apr 2010 22:48:01 +0000 (15:48 -0700)
src/rgw/rgw_rest.cc

index fe160d39fe58fb8718beb9b3411396307c0789a4..f338f496cbf11f13921e7bf38a8efa27560b4ad6 100644 (file)
@@ -406,19 +406,22 @@ void init_entities_from_header(struct req_state *s)
   s->object = NULL;
   s->object_str = "";
 
-  string h(s->host);
-
-  cerr << "host=" << s->host << std::endl;
-  int pos = h.find("s3.");
-
-  if (pos > 0) {
-    string encoded_bucket = h.substr(0, pos-1);
-    url_decode(encoded_bucket, s->bucket_str);
-    s->bucket = s->bucket_str.c_str();
-    s->host_bucket = s->bucket;
-  } else {
-    s->host_bucket = NULL;
-  }
+  int pos;
+  if (s->host) {
+    string h(s->host);
+    
+    cerr << "host=" << s->host << std::endl;
+    pos = h.find("s3.");
+    
+    if (pos > 0) {
+      string encoded_bucket = h.substr(0, pos-1);
+      url_decode(encoded_bucket, s->bucket_str);
+      s->bucket = s->bucket_str.c_str();
+      s->host_bucket = s->bucket;
+    } else {
+      s->host_bucket = NULL;
+    }
+  } else s->host_bucket = NULL;
 
   const char *req_name = s->path_name;
   const char *p;