Example #1
0
File: HTTP.php Project: techart/tao
 public static function merge_response($res1, $res2)
 {
     $res1 = Net_HTTP::Response($res1);
     $res2 = Net_HTTP::Response($res2);
     $res = new Net_HTTP_Response();
     $res->status($res2->status->code != Net_HTTP::OK ? $res2->status : $res1->status);
     $res->headers(array_merge($res1->headers->as_array(), $res2->headers->as_array()));
     if (empty($res2->body)) {
         $res->body($res1->body);
     }
     if (empty($res1->body)) {
         $res->body($res2->body);
     }
     /*if ((is_string($res1->body) || $res1->body instanceof Core_StringifyInterface) &&
       (is_string($res1->body) || $res1->body instanceof Core_StringifyInterface))
       $res->body = $res1->body . $res2->body;*/
     return $res;
 }