Skip to content

Commit

Permalink
Some hanging in feof/fgets on redirects that i cant seem to fix :(
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Mar 26, 2012
1 parent ef0eabc commit cd11f09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
35 changes: 17 additions & 18 deletions lib/Doctrine/KeyValueStore/Http/StreamClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,18 @@ public function request($method, $url, $body = null, array $headers)
}
$header = rtrim($header);

// TODO SSL support?
$opts = array(
'http' => array(
'method' => $method,
'content' => $body,
'max_redirects' => 2,
'ignore_errors' => false,
'user_agent' => 'Doctrine KeyValueStore',
'timeout' => $this->options['timeout'],
'header' => $header,
'protocol_version' => '1.1',
),
);
'http' => array(
'method' => $method,
'content' => $body,
'max_redirects' => 0,
'ignore_errors' => true,
'user_agent' => 'Doctrine KeyValueStore',
'timeout' => $this->options['timeout'],
'header' => $header,
'protocol_version' => '1.1',
),
);

$httpFilePointer = @fopen(
$url,
Expand All @@ -94,12 +93,6 @@ public function request($method, $url, $body = null, array $headers)
throw new \RuntimeException("Error sending to " . $host . ": " . $error['message']);
}

// Read request body
$body = '';
while ( !feof( $httpFilePointer ) ) {
$body .= fgets( $httpFilePointer );
}

$metaData = stream_get_meta_data( $httpFilePointer );
// The structure of this array differs depending on PHP compiled with
// --enable-curlwrappers or not. Both cases are normally required.
Expand All @@ -122,6 +115,12 @@ public function request($method, $url, $body = null, array $headers)
throw \RuntimeException('Error sending to ' . $host . ': Received an empty response or not status code');
}

// Read request body
$body = '';
while ( ! feof( $httpFilePointer ) ) {
$body .= fgets( $httpFilePointer );
}

// Create repsonse object from couch db response
return new Response($headers['status'], $body, $headers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public function testCrud()
$auth
);

#$response = $storage->createTable("test");
#var_dump($reponse);
$storage->insert("test", array("dist" => "foo", "range" => 400), array("foo" => "bar"));
$storage->insert("test", array("dist" => "foo", "range" => time()), array("foo" => "bar"));
}
}

0 comments on commit cd11f09

Please sign in to comment.