Permalink
Browse files

Merge pull request #12 from fhossain/master

Fix Phirehose to make length delimited requests properly
  • Loading branch information...
2 parents 181a5d6 + ec5056c commit 42849de6fcb35d84497b354af10a8adcc0c69ac8 @fennb fennb committed Dec 1, 2011
Showing with 9 additions and 10 deletions.
  1. +9 −10 lib/UserstreamPhirehose.php
@@ -7,7 +7,6 @@
const CONNECT_OAUTH = 'oauth';
const CONNECT_BASIC = 'basic';
- protected $status_length_base = 16; // for some reason, the userstream uses hexadecimal status lengths
protected $auth_method;
@@ -297,13 +296,13 @@ protected function connect_oauth() {
$postData = http_build_query($requestParams);
// Oauth tokens
- $oauthHeader = $this->getOAuthHeader('POST', $url);
+ $oauthHeader = $this->getOAuthHeader('POST', $url, $requestParams);
// Do it
- fwrite($this->conn, "POST " . $urlParts['path'] . " HTTP/1.1\r\n");
+ fwrite($this->conn, "POST " . $urlParts['path'] . " HTTP/1.0\r\n");
fwrite($this->conn, "Host: " . $urlParts['host'].':'.$port . "\r\n");
- #fwrite($this->conn, "Content-type: application/x-www-form-urlencoded\r\n");
- #fwrite($this->conn, "Content-length: " . strlen($postData) . "\r\n");
+ fwrite($this->conn, "Content-type: application/x-www-form-urlencoded\r\n");
+ fwrite($this->conn, "Content-length: " . strlen($postData) . "\r\n");
#fwrite($this->conn, "Accept: */*\r\n");
#fwrite($this->conn, 'Authorization: Basic ' . $authCredentials . "\r\n");
fwrite($this->conn, $oauthHeader."\r\n");
@@ -312,10 +311,10 @@ protected function connect_oauth() {
fwrite($this->conn, $postData . "\r\n");
fwrite($this->conn, "\r\n");
- $this->log("POST " . $urlParts['path'] . " HTTP/1.1");
+ $this->log("POST " . $urlParts['path'] . " HTTP/1.0");
$this->log("Host: " . $urlParts['host'].':'.$port);
- #$this->log("Content-type: application/x-www-form-urlencoded");
- #$this->log("Content-length: " . strlen($postData));
+ $this->log("Content-type: application/x-www-form-urlencoded");
+ $this->log("Content-length: " . strlen($postData));
#$this->log("Accept: */*");
#$this->log('Authorization: Basic ' . $authCredentials);
$this->log($oauthHeader);
@@ -486,8 +485,8 @@ protected function generateSignature($method = null, $url = null, $params = null
}
- protected function getOAuthHeader($method, $url) {
- $params = $this->prepareParameters($method, $url);
+ protected function getOAuthHeader($method, $url, $data) {
+ $params = $this->prepareParameters($method, $url, $data);
$oauthHeaders = $params['oauth'];
$urlParts = parse_url($url);
$oauth = 'Authorization: OAuth realm="' . $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path'] . '", ';

0 comments on commit 42849de

Please sign in to comment.