Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curl & Proxies #101

Closed
stepanselyuk opened this issue Jun 3, 2014 · 5 comments
Closed

Curl & Proxies #101

stepanselyuk opened this issue Jun 3, 2014 · 5 comments

Comments

@stepanselyuk
Copy link

@stepanselyuk stepanselyuk commented Jun 3, 2014

In some case the Facebook fix for calculate Curl headers (affected version) in FacebookCurlHttpClient does not fix all cases (according my logs and I got error 601 randomly), so I've changed code of fixing header size:

private function getHeaderSize() {

        $headerSize = self::$facebookCurl->getinfo( CURLINFO_HEADER_SIZE );

        // This corrects a Curl bug where header size does not account
        // for additional Proxy headers.
        if ( self::needsCurlProxyFix() ) {

            if ( preg_match( '/Content-Length: (\d+)/', $this->rawResponse, $m ) ) {

                $headerSize = mb_strlen( $this->rawResponse ) - $m[ 1 ];
            }
            elseif ( stripos( $this->rawResponse, self::CONNECTION_ESTABLISHED ) !== false ) {

                $headerSize += mb_strlen( self::CONNECTION_ESTABLISHED );
            }
        }

        return $headerSize;
}

And that error 601 does not occurred anymore.

@stepanselyuk
Copy link
Author

@stepanselyuk stepanselyuk commented Jun 3, 2014

I've found the case:

HTTP/1.0 200 Connection established
Proxy-agent: Kerio Control/7.1.1 build 1971

HTTP/1.1 200 OK
ETag: "5cda087310bbcd784e519292768580d683236e09"
Content-Type: application/json; charset=UTF-8
Pragma: no-cache
Access-Control-Allow-Origin: *
X-FB-Rev: 1272844
Cache-Control: private, no-cache, no-store, must-revalidate
Expires: Sat, 01 Jan 2000 00:00:00 GMT
X-FB-Debug: tHoKhGeGW3vBjkYKlk/zSpKDhDpQXwFIGa3STiCmcPg=
Date: Tue, 03 Jun 2014 09:41:24 GMT
Connection: keep-alive
Content-Length: 228

Detected headers size from Curl: 426
Content-Length: 228
Calculated header size: 510

Loading

@SammyK
Copy link
Contributor

@SammyK SammyK commented Jun 3, 2014

+1 for Guzzle! :)

Loading

@roman02
Copy link

@roman02 roman02 commented Jun 4, 2014

I'd really hate struggling with some random errors on this layer. I keep recalling numerous reports from people about getting zero when calling getUser() using the the old SDK. Such errors are VERY expensive for a business.

Loading

@gfosco
Copy link
Contributor

@gfosco gfosco commented Jun 12, 2014

Can you submit a PR for this @stepanselyuk ?

Loading

@stepanselyuk
Copy link
Author

@stepanselyuk stepanselyuk commented Jun 12, 2014

Ok done #116.

Loading

@gfosco gfosco closed this Jun 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants