dtcyv3985 2013-08-01 18:37
浏览 139
已采纳

Google云端存储:上传对象正在返回HTTP / 1.1 100继续

I'm noticing that, since July 29 2013, The GCS webservice has started returning "HTTP/1.1 100 Continue" instead of the usual "HTTP/1.1 200 OK"(followed by some metadata about the server).

This is seen when doing a PUT Object on my end.

My question is, how do I resolve this? Do I just re-send the request? Do I re-direct the request to another location?


here is what my request looks like:

    $headers = array('Host: '.$bucket.'.commondatastorage.googleapis.com',
                    'Date: '.$timestamp, $version_header, 'Content-Type: text/plain',
                    $project_header, 'Content-Length: '.filesize($objectPath),
                    'Authorization: OAuth '.$accessToken);

    $c   = curl_init();
    curl_setopt($c, CURLOPT_URL, $url);
    curl_setopt($c, CURLOPT_PUT, 1);
    curl_setopt($c, CURLOPT_INFILE, $fp); 
    curl_setopt($c, CURLOPT_INFILESIZE, filesize($objectPath)); 
    curl_setopt($c, CURLOPT_HEADER, 1);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($c, CURLOPT_TIMEOUT, 60); //timeout in 60s
    curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
    $response = curl_exec($c);

  • 写回答

1条回答 默认 最新

  • douba6365 2013-08-01 18:59
    关注

    It's a feature of HTTP 1.1;

    Basically, your client sends the header only with an extra line;

    Expect: 100-continue
    

    ...and waits with posting the body for a few hundred milliseconds. If the timeout expires or there is a 100 Continue response from the server, the client proceeds with the upload, if there's a 417 Expectation Failed, the upload is aborted.

    That allows the server to check if it will accept the request before the upload. For example if the size of a file is greater than the remaining quota of Google Cloud Storage, it would be useless to upload it before getting refused.

    When the upload is complete, you will get an additional 200 OK response as usual.

    EDIT:

    I see you're running PHP. More about this in PHP/Curl is available in this question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路