Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding query string to URI for GET FormRequests, see #76 #77

Closed
wants to merge 2 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 15, 2012
  1. @jostick
Commits on May 18, 2012
  1. @jostick

    Fixed coding style

    jostick authored
This page is out of date. Refresh to see the latest.
View
2  lib/Buzz/Client/Curl.php
@@ -22,7 +22,7 @@ static protected function setCurlOptsFromRequest($curl, Message\Request $request
{
$options = array(
CURLOPT_CUSTOMREQUEST => $request->getMethod(),
- CURLOPT_URL => $request->getHost().$request->getResource(),
+ CURLOPT_URL => $request->getUrl(),
CURLOPT_HTTPHEADER => $request->getHeaders(),
);
View
2  lib/Buzz/Client/FileGetContents.php
@@ -39,7 +39,7 @@ public function send(Message\Request $request, Message\Response $response)
}
$context = stream_context_create($this->getStreamContextArray($request));
- $url = $request->getHost().$request->getResource();
+ $url = $request->getUrl();
$level = error_reporting(0);
$content = file_get_contents($url, 0, $context);
View
16 lib/Buzz/Message/FormRequest.php
@@ -74,6 +74,10 @@ public function getHeaders()
{
$headers = parent::getHeaders();
+ if ($this->getMethod() == self::METHOD_GET) {
+ return $headers;
+ }
+
if ($this->isMultipart()) {
$headers[] = 'Content-Type: multipart/form-data; boundary='.$this->getBoundary();
} else {
@@ -83,8 +87,20 @@ public function getHeaders()
return $headers;
}
+ public function getUrl() {
+ if ($this->getMethod() == self::METHOD_GET) {
+ return parent::getUrl() . '?' . http_build_query($this->getFields());
+ }
+
+ return parent::getUrl();
+ }
+
public function getContent()
{
+ if ($this->getMethod() == self::METHOD_GET) {
+ return null;
+ }
+
if (!$this->isMultipart()) {
return http_build_query($this->fields);
}
Something went wrong with that request. Please try again.