Skip to content

Instantly share code, notes, and snippets.

@Thinkscape
Created January 15, 2014 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thinkscape/8433897 to your computer and use it in GitHub Desktop.
Save Thinkscape/8433897 to your computer and use it in GitHub Desktop.
<?php
include "vendor/autoload.php";
$url = 'https://github.com?abc';
$client = new Guzzle\Http\Client();
$req = $client->get($url);
var_dump("The url we are looking for: $url");
var_dump("The url after parsing: " . $req->getUrl(false));
if($url !== $req->getUrl(false)){
echo "URL has been broken during parsing\n";
} else {
echo "All is good\n";
}
$url = \Guzzle\Http\Url::factory('https://github.com');
$url->setQuery([100 => \Guzzle\Http\QueryString::BLANK]);
var_dump('Url before sending: ' . $url);
$req = $client->get($url);
var_dump('Url after sending: ' . $req->send()->getEffectiveUrl());
if((string)$url !== $req->getResponse()->getEffectiveUrl()){
echo "URL has been changed when sending request!\n";
} else {
echo "All is good\n";
}
string(50) "The url we are looking for: https://github.com?abc"
string(46) "The url after parsing: https://github.com?abc="
URL has been broken during parsing
string(42) "Url before sending: https://github.com?100"
string(42) "Url after sending: https://github.com?100="
URL has been changed when sending request!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment