xp-framework / http

HTTP protocol support for the XP Framework
2 stars 2 forks source link

Allow supplying path along with parameters #17

Open thekid opened 8 years ago

thekid commented 8 years ago

Example:

$conn= new HttpConnection('http://example.com');

// Previously both of the following worked
$conn->get(['name' => 'Test', 'mail' => 'test@example.com']);
$conn->get('name=Test&mail=test@example.com');

// New functionality
$conn->get('/index.php');
$conn->get('/index.php?name=Test&mail=test@example.com');
thekid commented 8 years ago

We could go a bit further and support relative URLs, too, so that get() and friends' first arguments would accept most of the things you'd put into a <a href="...">...</a>. To reduce suprises, we should really deprecate pasing a string with paramters only (like 'name=Test&mail=test@example.com'), and require prefixing that with ? (as you'd have to in your link):

// Deprecated, raises warning
$conn->get('name=Test&mail=test@example.com');

// Works, appends to base URL passed to constructor, just as would happen if in <a href="...">
$conn->get('?name=Test&mail=test@example.com');

@mikey179 @kiesel what do you think?