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

Please provide proper attribution for this work #1

Open
gnif opened this issue Apr 8, 2019 · 0 comments
Open

Please provide proper attribution for this work #1

gnif opened this issue Apr 8, 2019 · 0 comments

Comments

@gnif
Copy link

gnif commented Apr 8, 2019

https://stackoverflow.blog/2009/06/25/attribution-required/

https://stackoverflow.com/questions/9183178/can-php-curl-retrieve-response-headers-and-body-in-a-single-request/41135574#41135574

curl_setopt( $ch, CURLOPT_HEADERFUNCTION, function ( $ch, $header ) use ( &$receivedHeaders ) {
$len = strlen( $header );
$header = explode( ':', $header, 2 );
if ( count( $header ) < 2 ) { // ignore invalid headers
return $len;
}
$name = strtolower( trim( $header[0] ) );
if ( ! array_key_exists( $name, $receivedHeaders ) ) {
$receivedHeaders[ $name ] = [ trim( $header[1] ) ];
} else {
$receivedHeaders[ $name ][] = trim( $header[1] );
}
return $len;
} );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant