-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Buzz\Listener; | ||
|
||
use Buzz\Message\MessageInterface; | ||
use Buzz\Message\RequestInterface; | ||
|
||
class BasicAuthListener implements ListenerInterface | ||
{ | ||
private $username; | ||
private $password; | ||
|
||
public function __construct($username, $password) | ||
{ | ||
$this->username = $username; | ||
$this->password = $password; | ||
} | ||
|
||
public function preSend(RequestInterface $request) | ||
{ | ||
$request->addHeader('Authorization: Basic '.base64_encode($this->username.':'.$this->password)); | ||
} | ||
|
||
public function postSend(RequestInterface $request, MessageInterface $response) | ||
{ | ||
} | ||
} |
fb1d2a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
How can we use this stuff?
fb1d2a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$browser->addListener(new BasicAuthListener($username, $password))
fb1d2a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks