Appreciate it Thanks Hugo's iPhone
pf shineyear <shin...@gmail.com> 於 2011/11/23 12:47 寫道: > php curl have a shit feature: can not post an empty http header, so if you > want to perform a command like this in php: > > swift -A http://10.38.10.127:8080/auth/v1.0 -U AUTH_testa27:AUTH_testu27 -K > testp post -r ' ' mycontainer2 > > the "X-Container-Read" will not be send, so you can not make a container > unpublic from public > > i write an example code to show how make it work with php, just use ' not " > and plus \n at the end > > hope can make some help > > > <?php > > $prefix = "AUTH_"; > $account_name = $prefix."testa27"; > $user_name = $prefix."testu27"; > $user_pass = "testp"; > $container = "mycontainer2"; > $user_token = "AUTH_tkb21f5fcfea144cf9a99ed1de9a577db2"; > $path = "/v1/".$account_name."/".$container; > > > #if you want to make container public use this > #$http_headers = array("X-Auth-Token: ".$user_token, 'X-Container-Read: > .r:*'); > > #if you want to make container not public use this > $http_headers = array("X-Auth-Token: ".$user_token, 'X-Container-Read: > \n'); > > print_r($http_header); > > $ch = curl_init(); > > curl_setopt($ch, CURLOPT_URL, "http://10.38.10.127:8080".$path); > curl_setopt($ch, CURLOPT_POST, 1); > curl_setopt($ch, CURLOPT_HTTPHEADER, $http_headers); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); > curl_setopt($ch, CURLINFO_HEADER_OUT, true); > > print "test set container public\n"; > > curl_exec($ch); > > $headers = curl_getinfo($ch, CURLINFO_HEADER_OUT); > > print_r($headers); > > if (!curl_errno($ch)) > { > $info = curl_getinfo($ch); > > if ((int)($info['http_code'] / 100) != 2) > { > print "set container public return error > ".$info['http_code']."\n"; > return -1; > } > } > else > { > print "set container public error\n"; > return -2; > } > > curl_close($ch); > > ?> > _______________________________________________ > Mailing list: https://launchpad.net/~openstack > Post to : openstack@lists.launchpad.net > Unsubscribe : https://launchpad.net/~openstack > More help : https://help.launchpad.net/ListHelp
_______________________________________________ Mailing list: https://launchpad.net/~openstack Post to : openstack@lists.launchpad.net Unsubscribe : https://launchpad.net/~openstack More help : https://help.launchpad.net/ListHelp