-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs: update content and various tweaks to the markdown
The "Documentation" section of the https://requests.ryanmccue.info/ website is automatically generated from the files in the `docs` folder. The last time the site was generated was in 2016. Since then a lot has changed in GH Pages and a lot of the [dependencies](https://pages.github.com/versions/) used to generate a site have been updated to newer releases. This commit makes various tweaks to the markdown for improved rendering on the current GH Pages setup. While going through the pages, I've also done a cursory review of the content and fixed up information which was extremely outdated or plain incorrect by now. Includes: * Use spaces not tabs for indentation in markdown files. * Fixing up various URLs/links. * Removal of various uses of ableist language. * Punctuation fixes.
- Loading branch information
Showing
9 changed files
with
124 additions
and
140 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
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
Custom Authentication | ||
===================== | ||
Custom authentication handlers are designed to be extremely simple to write. | ||
Custom authentication handlers are designed to be straight-forward to write. | ||
In order to write a handler, you'll need to implement the `Requests_Auth` | ||
interface. | ||
|
||
An instance of this handler is then passed in by the user via the `auth` | ||
An instance of this handler can then be passed to Requests via the `auth` | ||
option, just like for normal authentication. | ||
|
||
Let's say we have a HTTP endpoint that checks for the `Hotdog` header and | ||
authenticates you if said header is set to `Yummy`. (I don't know of any | ||
authenticates the call if said header is set to `Yummy`. (I don't know of any | ||
services that do this; perhaps this is a market waiting to be tapped?) | ||
|
||
```php | ||
class MySoftware_Auth_Hotdog implements Requests_Auth { | ||
protected $password; | ||
protected $password; | ||
|
||
public function __construct($password) { | ||
$this->password = $password; | ||
} | ||
public function __construct($password) { | ||
$this->password = $password; | ||
} | ||
|
||
public function register(Requests_Hooks &$hooks) { | ||
$hooks->register('requests.before_request', array($this, 'before_request')); | ||
} | ||
public function register(Requests_Hooks &$hooks) { | ||
$hooks->register('requests.before_request', array($this, 'before_request')); | ||
} | ||
|
||
public function before_request(&$url, &$headers, &$data, &$type, &$options) { | ||
$headers['Hotdog'] = $this->password; | ||
} | ||
public function before_request(&$url, &$headers, &$data, &$type, &$options) { | ||
$headers['Hotdog'] = $this->password; | ||
} | ||
} | ||
``` | ||
|
||
We then use this in our request calls: | ||
We then use this in our request calls like this: | ||
|
||
``` | ||
```php | ||
$options = array( | ||
'auth' => new MySoftware_Auth_Hotdog('yummy') | ||
'auth' => new MySoftware_Auth_Hotdog('yummy') | ||
); | ||
$response = Requests::get('http://hotdogbin.org/admin', array(), $options); | ||
``` | ||
|
||
(For more information on how to register and use hooks, see the [hooking | ||
system documentation][hooks]) | ||
For more information on how to register and use hooks, see the [hooking | ||
system documentation][hooks]. | ||
|
||
[hooks]: hooks.md | ||
[hooks]: hooks.md |
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
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
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
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
Proxy Support | ||
============= | ||
|
||
You can easily make requests through HTTP proxies. | ||
Making requests through HTTP proxies is fully supported. | ||
|
||
To make requests through an open proxy, specify the following options: | ||
|
||
```php | ||
$options = array( | ||
'proxy' => '127.0.0.1:3128' | ||
'proxy' => '127.0.0.1:3128' | ||
); | ||
Requests::get('http://httpbin.org/ip', array(), $options); | ||
``` | ||
|
||
If your proxy needs you to authenticate, the option will become an array like | ||
the following: | ||
in the following example: | ||
|
||
```php | ||
$options = array( | ||
'proxy' => array( '127.0.0.1:3128', 'my_username', 'my_password' ) | ||
'proxy' => array( '127.0.0.1:3128', 'my_username', 'my_password' ) | ||
); | ||
Requests::get('http://httpbin.org/ip', array(), $options); | ||
``` |
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
Oops, something went wrong.