Coder Social home page Coder Social logo

buzz's People

Contributors

asm89 avatar bburnichon avatar dol avatar everzet avatar gelolabs avatar hellpat avatar honzatrtik avatar jfsimon avatar koc avatar kriswallsmith avatar lyrixx avatar makasim avatar marijn avatar mattsches avatar mheap avatar milad avatar minishlink avatar nick-zh avatar nyholm avatar peterfrankjohnson avatar relo-san avatar rndstr avatar royopa avatar rybakit avatar seldaek avatar snpy avatar stloyd avatar stof avatar sunkan avatar troelskn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

buzz's Issues

Easy/best way to do unit tests

I was wondering what would be the best way to perform unit tests on a webservice client built using Buzz.
I reckon I should write some "mock data" client, so that the test does not require an internet connection and returns a response we can depend on (so that are tests won't fail if the webservice is unreachable).

What are your opinions on this and has anyone been working on this before?

it would be awesome if this library would throw exceptions on connection errors

Right now I have the following code, which is taken straight from the README:

    $browser = new Browser();
    $response = $browser->get($url);

Which results in the following:

Warning: file_get_contents(http://localhost:8081/stuff/updateShow/5/6) [function.file-get-contents]: failed to open stream: Connection refused in /home/penny/src/stuff/src/vendor/Buzz/lib/Buzz/Client/FileGetContents.php line 40

Which is being caught by I guess the default Symfony2 error handler. I would ideally like it to actually throw an exception so I can handle it with a try catch block and do something myself. That would have high levels of awesomosity.

I guess being able to have exceptions thrown for various sensible http return codes (maybe a configurable list?) would be helpful too, although at the moment connection errors are worrying me more.

setting a cookie value

is it possible to set a specific Value for the cookie, before fetching a page using the Buzz php light weight client?

i want to set splash = 0 for a specific host, to avoid a pop-up they have.

Content-Type: multipart/form-data

A FormRequest may only have the Content-Type "multipart/form-data", if a file upload is detected. In my case, i need to post a formular, which has enctype="multipart/form-data" without any file upload fields.

Is there a possibility, that my work can be done with Buzz some day?

Concrete Clients send method signature does not conform to ClientInterface

In Buzz\Client\ClientInterface, the method signature for the send method is:

public function send(RequestInterface $request, MessageInterface $response);

In Buzz\Client\Curl and MultiCurl, the method signature for the send method is:

public function send(RequestInterface $request, MessageInterface $response, array $options = array())

Additionally, Curl and MultiCurl may throw ClientException which is not documented in ClientInterface.

Please update ClientInterface's method signature to include the $options array argument. Update all other concrete client class send methods to conform to this signature. Add the throws ClientException annotation to ClientInterface doc block.

Add Base URL Functionality

Is there any interest in adding the ability to specify the base URL for a browser instance?

It would be ideal if you could simply create a Browser with a base URL, then pass relative paths from that point forward. This wouldn't impact backwards compatibility, since you could have this parameter default to null and keep the existing functionality as is.

I envision that the base URL could be the third constructor parameter in Buzz\Browser. From here, the call() function could determine whether it needs to build the URL from the base URL or if it can move forward with the existing functionality.

I see a major benefit to this because it removes the need for developers to build the URLs themselves. Potentially, the developer could have a service that has a base URL specified and could then pass relative URLs from that point forward. This makes different URLs between different environments much less of a concern.

I'd be happy to add this feature. I just wanted to get a gauge of how receptive you were to it.
Thanks!

Missing mutual authentication methods

I've found out that implementing mutual authentication using Buzz is quite impossible.

We need to be able to set path to the ssl certificate, ssl private key and ssl certificate authority list. I guess Passing direct options to the Curl would not be possible, due to the fact that you use adapters, which might mean that you plan on adding support for different clients later on.

Timeout detection?

Hi

I am having timeouts in some requests and I would like to control them.
Right now, I am checking emptyness in Response Content to detect timeouts, is there a cleaner way to check timeout inside Buzz Library?

I am using Curl as Client.

Best regards

Post not working in file_get_contents client

I wanted to do a simple test. Send out a post to another location. It calls a file that is simply doing a print_r on $_POST.

$browser = new Buzz\Browser();
$response = $browser->post('http://test', array(), array('id' => 123, 'name' => 'tester'));

echo $response;

Returns
HTTP/1.1 200 OK
Date: Sat, 29 Sep 2012 03:48:57 GMT
Server: Apache
X-Powered-By: PHP/5.3.10-1ubuntu3.2
Vary: Accept-Encoding
Content-Length: 10
Connection: close
Content-Type: text/html

Array
(
)

$browser = new Buzz\Browser(new Buzz\Client\Curl());
$response = $browser->post('http://test', array(), array('id' => 123, 'name' => 'tester'));

echo $response;

Returns

HTTP/1.1 200 OK
Date: Sat, 29 Sep 2012 04:07:01 GMT
Server: Apache
X-Powered-By: PHP/5.3.10-1ubuntu3.2
Vary: Accept-Encoding
Content-Length: 47
Content-Type: text/html

Array
(
[id] => 123
[name] => tester
)

The inconsistency is in the handling of the request content on post. I can see curl is handling this with a switch, but there is no equivalent on file_get_contents. Is this a limitation of file_get_contents itself I'm unaware of or simply not fully implemented?

More Buzz specific exceptions?

For example the Curl client throws a RuntimeException if curl returns an error. Would it be an idea to extend the RuntimeException with a Buzz\Exception\ClientException class or something?

Reason I'm asking is because we have long running processes consuming an api. Sometimes this API fails and the RuntimeException bubbles up. It would be nice to be able to catch the exceptions generated by Buzz and then requeue the current message being processed and go on with the next one. Currently the process crashes.

Unknown class finfo in FormUpload

When using FormUpload, I get an error because of an unknown class finfo, used line 108 of this file. Where does it come from ?

And as it does not seem to be part of PHP itself, you should check first if it exists.

SSL url throws a runtime exception

Here is a code snippet to reproduce:

error_reporting(E_ALL); 
ini_set('display_errors', true); 
$browser = new Buzz\Browser();
$response = $browser->get("https://www.google.com");

Setting the scheme to https instead of http throws the following exception in the browser:

Fatal error: Uncaught exception 'RuntimeException' with message 'file_get_contents(https://www.google.com/): failed to open stream: operation failed' in /www/api/Buzz/lib/Buzz/Client/FileGetContents.php on line 49 RuntimeException: file_get_contents(https://www.google.com/): failed to open stream: operation failed in /www/api/Buzz/lib/Buzz/Client/FileGetContents.php on line 49 Call Stack: 0.0004 662440 1. {main}() /www/api/new_document_test_buzz.php:0 0.0020 748224 2. Buzz\Browser->get() /www/api/new_document_test_buzz.php:30 0.0024 776160 3. Buzz\Browser->call() /www/api/Buzz/lib/Buzz/Browser.php:25 0.0027 788520 4. Buzz\Browser->send() /www/api/Buzz/lib/Buzz/Browser.php:71 0.0028 803168 5. Buzz\Client\FileGetContents->send() /www/api/Buzz/lib/Buzz/Browser.php:114

Do you need to use the CURL client or something different? I wonder if the error message could be more clear about how to remedy the situation.

Add a composer.json file

Hi Kris,

I'm using Buzz mostly in Geocoder and I wonder if you would like to add a composer.json file to Buzz ? Or, in another words, do you want to add Buzz on packagist.org ?

Regards,
William

Minimal PHP Version in composer.json

Hi

In composer.json Buzz is configured to require at least 5.3.0, but I think that there is one point where compatibility is broken and only works from 5.3.3 onwards.

In Buzz\Message\Request (line 91)

        $info = parse_url($url);

        if (false === $info) {
            throw new \InvalidArgumentException(sprintf('The URL "%s" is invalid.', $url));
        }

But looking at http://www.php.net/manual/en/function.parse-url.php Changelog

5.3.3 Removed the E_WARNING that was emitted when URL parsing failed.

And in my setup with PHP 5.3.2 Unit tests are broken here unless @parse_url($url) is done as it just gives a warning

What are your thoughts about this?

Using curl - POST request made when following 302 redirect from POST request

The title doesn't make this sound like it should be an issue - Buzz is conforming to the standards. But, the behaviour does not reflect what real browsers do; all major browsers currently change the method from POST to GET. Since the class is called Browser, do you think it should reflect the behaviour of a real browser?

From RFC2616 - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

  Note: RFC 1945 and RFC 2068 specify that the client is not allowed
  to change the method on the redirected request.  However, most
  existing user agent implementations treat 302 as if it were a 303
  response, performing a GET on the Location field-value regardless
  of the original request method. The status codes 303 and 307 have
  been added for servers that wish to make unambiguously clear which
  kind of reaction is expected of the client.

Curl performs like a browser by default - if configured to follow redirects, it will use a GET for a 302 on a POST - but since CURLOPT_CUSTOMREQUEST is set in AbstractCurl.php this behaviour is changed.

Get http status of response?

Am making a request. Everything works fine, until there is an other HTTP status than 200, for example 404. This then just returns an empty string. Any chance how to catch the http status?

Use of undefined constant CURLOPT_PROTOCOLS - assumed 'CURLOPT_PROTOCOLS'

Hello,

during unit test, we observe following notice :

ErrorException: Notice: Use of undefined constant CURLOPT_PROTOCOLS - assumed 'CURLOPT_PROTOCOLS' in /data/jenkins_home/jobs/mockserver-integration-head/workspace/vendor/kriswallsmith/buzz/lib/Buzz/Client/AbstractCurl.php line 21

PHP 5.4.6 (Linux)

Buzz installed via composer :

"require":{
"php":">=5.4.4",
"sensio/buzz-bundle": "dev-master"

Add Content-Length to headers

It'd be really great if you could set a flag so that when a request goes out, it includes the Content-Length as part of the header. I'm not really seeing a way to do that, and having to calculate that value by hand seems excessive.

Edit: I meant this in the context of using Buzz\Browser->post().

Multi curl hangs forever with some kind of configurations

On my production server multicurl hangs forever.

The piece of code that hangs is:

# lib/Buzz/Client/MultiCurl.php

//...
while ($active && CURLM_OK == $mrc) {
     if (-1 != curl_multi_select($curlm)) {
          do {
               $mrc = curl_multi_exec($curlm, $active);
          } while (CURLM_CALL_MULTI_PERFORM == $mrc);
     }
}
//...

It does not seem to ever enter the if (-1 != curl_multi_select($curlm)) { block.

These are my curl settings on production server:

curl

cURL support => enabled
cURL Information => 7.32.0
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => Yes
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => No
SSL => Yes
SSPI => No
TLS-SRP => Yes
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, smtp, smtps, telnet, tftp
Host => x86_64-pc-linux-gnu
SSL Version => OpenSSL/1.0.1e
ZLib Version => 1.2.8

Everything works fine on dev.

Let me know if further details are needed

Weird file uploading

I tried to use FormUpload to do a file upload with Buzz. But in the script receiving it, the file content is available in $_POST whereas I would expect receiving a file in $_FILES. I tried it with both the FileGetContents and the Curl clients.

Wrong assumptions

Hi Kris,

I had really strange situation in order to use your library. The problem doesn't exists when curl send request to server with linux on the board and apache. Problems appear when curl send request to server with windows server on the board and IIS7. I found the issue and it looks like you use CURLOPT_CUSTOMREQUEST to set up METHOD for every kind what is wrong from IIS point of view and following definition:

  • CURLOPT_CUSTOMREQUEST : A custom request method to use instead of "GET" or "HEAD" when doing a HTTP request. This is useful for doing "DELETE" or other, more obscure HTTP requests.

Using the option as POST makes a lot of problems and is really hard to debug. You should use definitely CURLOPT_POST for posts requests instead of CURLOPT_CUSTOMREQUEST. I read your code and looks like you have to change assumptions a bit.

V

Add proxy settings ability on Curl Client?

The main utility of Curl versus file_get_content is the proxy ability and HTTP auth.

But there is now way of set CURL options without hack or manual low level client manipulation like:

$client = new \Buzz\Client\Curl();
curl_setopt($client->getCurl(), CURLOPT_PROXY, 'blablabla');

If fact, a setOption method is missing on the Curl Client, and perhaps an array of curl option (CURLOPT_*) could be given as a constructor parameter.

What do you think about that?
I might be able to provide a patch as soon as I can.

Upload Files via POST

This is probably a really easy one, but I'm just stuck. I want to upload a file to a service. I don't have a form that is submitted, but rather a (local) URI to that file. I would greatly appreciate a short example. I was already thinking about encoding it to BASE64 and send it, but there must be a nicer way.

AbstractCurl setOptionsFromRequest

When using the Curl client and server has open_basedir() defined, using CURL_FOLLOWLOCATION stops the script.

As I read on the web, this has been fixed by cURL but it seens that PHP doesn't updated it yet.

A solution exists (read: http://stackoverflow.com/questions/3890631/php-curl-with-curlopt-followlocation-error)

So, I extended your \Buzz\Client\Curl class and override your prepare() method, but setOptionsFromRequest() is private and so I can't call it from my class. So I opened \Buzz\Client\AbstractCurl and changed it to protected for enabling the method call.

Great library by the way!!!

MultiCurl Responses content

Hello

We try to use MultiCurl to send multiple request and then parse each response one by one.
Requests are done; but we want to get each response for each request.

I think the response in the flush() method is the last response for all the queued requests.

while (list($request, $response, $options, $curl) = array_shift($this->queue)) {
    static::populateResponse($curl, curl_multi_getcontent($curl), $response);            
    curl_multi_remove_handle($curlm, $curl);
}

So, how to handle multiple responses content with MultiCurl client ?

Hervé

Working Locally But Not When Deployed to Server

I am making requests to an API with Buzz. The requests work perfectly on my local development machine, but not when I deploy to my server.

Buzz is throwing a ClientException with a blank error message from line 63 of Client/FileGetContents.php. Not sure why it isn't working. Running PHP 5.3.27 on the server.

Error handling abstraction

Right now Buzz has a ignoreErrors setting on the client which can disable errors from being shown. However it does not really abstract the errors. In most cases an error would simply result in a notice, which is not nice.

It would be great if the user could expect a certain exception to be thrown in case of an error. Some Buzz\Client\Exception or similar.

Use of undefined constant CURLOPT_PROTOCOLS - assumed 'CURLOPT_PROTOCOLS' in vendor/kriswallsmith/buzz/lib/Buzz/Client/AbstractCurl.php line 21

Hello,

during unit test, we observe following notice :

ErrorException: Notice: Use of undefined constant CURLOPT_PROTOCOLS - assumed 'CURLOPT_PROTOCOLS' in /data/jenkins_home/jobs/mockserver-integration-head/workspace/vendor/kriswallsmith/buzz/lib/Buzz/Client/AbstractCurl.php line 21

PHP 5.4.6 (Linux)
  
Buzz installed via composer :
 kriswallsmith/buzz [dev-master e225550] : Lightweight HTTP client
  

"require":{
"php":">=5.4.4",
"sensio/buzz-bundle": "dev-master"

HTTP authentication

Add a mechanism for supporting Basic and Digest authentication. Use client support when possible (i.e. CURLOPT_USERPWD and CURLAUTH_DIGEST).

Basic authentication should be possible with a simple convenience method on the request object.

Digest authentication is more complicated because of the nonce that must be passed from response to request.

$browser->get('twitter.com') throws Notice

Hey,

when i try to get the content of twitter.com buzz throws a notice:

$browser = new Browser();
$response = $browser->get('twitter.com');
Notice: Undefined offset: 1 in (...)buzz\lib\Buzz\Message\Request.php line 99 (500 Internal Server Error)

urlencode $resource

I currently use some auto generated URLs that I query with Buzz. Some Urls use whitespaces that aren't encoded by Buzz. I think the Request class should do this by default.

Make FormRequest work with METHOD_GET and query string

Maybe I missed something. I just started using Buzz. But I would expect this code

$request = new FormRequest(FormRequest::METHOD_GET, '/tasks', 'taskserver.dev');
$request->addFields(array('search'=>'milk'));
$response = $this->browser->send($request);

makes a request like 'http://taskserver.dev/tasks?search=milk'. I couldn't get the query string part working. It doesn't seem to be supported at the moment.

If this is true, I could work on a patch.

ClassLoader.php

Was the class loader removed? I forked and added one, just can't remember If it was included before....

[CurlClient] Work when open_basedir is set

The problem came from the curl option CURLOPT_FOLLOWLOCATION that it doesn't work well with open_basedir directive.

The PHP Warning is triggered:

Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /home/http/symfony/vendor/buzz/lib/Buzz/Client/Curl.php line 138

As open_basedir it's a good security practice, would be great if Buzz can work with it.

Is this repo abandoned?

@kriswallsmith Has this repo been abandoned? Should someone else be added as a collaborator (@stof?) to get some of the pull requests merged here? It looks like it's been about 6 months since any commits have been merged. There are active discussions about the issues/pulls that are for this repo. Hate to see it fragmented.

Mailinglist?

Is there a mailing list or some documentation anywhere for this? I seem to have some issues and don't know where to get some help.

Problems sending character '+' in POST Requests

Hi

I am trying to get rid of Zend_HTTP_Client in order to use Buzz but I am having this problem.
If one of my POST Parameters contains character '+' it gets converted to ' ' instead of passing it correctly.

'+' character is always a dirty bitch on HTTP Requests, if you use it on GET you must pass it urlencoded and in POST it leads to problems most of the times.

I have tried Client\Curl and Client\FileGetContents, both having same problems

Have you got any solution for that? If it is impossible to fix it I will have to switch back to Zend_HTTP_Client as we need the '+' character to be sent.

Thanks for your time

Best regards

Add new version tag

Can you please add new version tag for current master state? I've got some issues using Buzz via composer. These are already fixed in master, but not in v0.9. I can't use dev-master in my project due to stability issues.
It would be great to have current master tag (0.10 for example?) to use at packagist.org

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.