当前位置: 首页>>代码示例>>PHP>>正文


PHP HttpResponse::isSuccessful方法代码示例

本文整理汇总了PHP中HttpResponse::isSuccessful方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpResponse::isSuccessful方法的具体用法?PHP HttpResponse::isSuccessful怎么用?PHP HttpResponse::isSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpResponse的用法示例。


在下文中一共展示了HttpResponse::isSuccessful方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: HandleOperationResponse

 /**
  * To handle the HttpResponse object of a HttpRequest POST request in
  * non-batching mode. This function will invoke ObjectContext::AttachLocation
  * which uses the value of HttpHeader with key 'Location' to set the Identity
  * and EditLink of current entry (ResourceBox) under process. Also populate the
  * entity instance with OData service returned values.
  *
  * @param HttpResponse $httpResponse
  */
 protected function HandleOperationResponse($httpResponse)
 {
     $resourceBox = $this->_changedEntries[$this->_entryIndex];
     if ($resourceBox->IsResource()) {
         $headers = $httpResponse->getHeaders();
         //Handle the POST Operation Response.
         //SDK will fire POST operation in three cases
         //1. AddLink [we will skip this case]
         //2. AddObject [$resourceBox->State == EntityStates::Added]
         //3. SetSaveStream on an entity which is just added using AddObject
         //   In this case the CheckAndProcessMediaEntryPost will set the state
         //   of the object to Modified.
         //   [($resourceBox->State == EntityStates::Modified) &&
         //      $this->_processingMediaLinkEntry) &&
         //     !$this->_processingMediaLinkEntryPut)]
         if ($resourceBox->State == EntityStates::Added || $resourceBox->State == EntityStates::Modified && $this->_processingMediaLinkEntry && !$this->_processingMediaLinkEntryPut) {
             $resourceBox->EntityETag = AtomParser::GetEntityEtag($httpResponse->getBody());
             $location = isset($headers[HttpRequestHeader::Location]) ? $headers[HttpRequestHeader::Location] : null;
             if ($httpResponse->isSuccessful()) {
                 if ($location == null) {
                     throw new ODataServiceException(Resource::NoLocationHeader, '', array(), null);
                 }
                 $this->_context->AttachLocation($resourceBox->getResource(), $location);
                 if ($resourceBox->State == EntityStates::Added) {
                     $atomEntry = null;
                     AtomParser::PopulateObject($httpResponse->getBody(), $resourceBox->getResource(), $uri, $atomEntry);
                 } else {
                     //After the POST operation for a media, state of corrosponding entity will be
                     //updated to Modified [earlier it will be Added] in CheckAndProcessMediaEntryPost
                     //function. So next will be a MERGE request, while generating body for this
                     //MERGE operation, the function CreateChangeSetBodyForResource will throw error
                     //if any of the Key field is null. So update the Key fields.
                     AtomParser::PopulateMediaEntryKeyFields($httpResponse->getBody(), $resourceBox->getResource());
                 }
             }
         }
         if ($this->_processingMediaLinkEntry && !$httpResponse->isSuccessful()) {
             $this->_processingMediaLinkEntry = false;
             if ($this->_processingMediaLinkEntryPut) {
                 $resourceBox->State = EntityStates::Added;
                 $this->_processingMediaLinkEntryPut = false;
             }
         }
     }
 }
开发者ID:silviogarbes,项目名称:phpodata,代码行数:54,代码来源:SaveResult.php


注:本文中的HttpResponse::isSuccessful方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。