[http] add pre-emptive basic authentication and fix header handling (#9584)

* add preemptive basic authentication

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>

* improve header handling

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>

* Update bundles/org.openhab.binding.http/README.md

Co-authored-by: t2000 <t2000@users.noreply.github.com>

Co-authored-by: t2000 <t2000@users.noreply.github.com>
This commit is contained in:
J-N-K
2020-12-31 12:23:32 +01:00
committed by GitHub
parent 1b5df97af5
commit eaae9780ea
5 changed files with 29 additions and 19 deletions

View File

@@ -18,14 +18,19 @@ It can be extended with different channels.
| `delay` | no | 0 | Delay between two requests in ms (advanced parameter). |
| `username` | yes | - | Username for authentication (advanced parameter). |
| `password` | yes | - | Password for authentication (advanced parameter). |
| `authMode` | no | BASIC | Authentication mode, `BASIC` or `DIGEST` (advanced parameter). |
| `authMode` | no | BASIC | Authentication mode, `BASIC`, `BASIC_PREEMPTIVE` or `DIGEST` (advanced parameter). |
| `commandMethod` | no | GET | Method used for sending commands `GET`, `PUT`, `POST`. |
| `contentType` | yes | - | MIME content-type of the command requests. Only used for `PUT` and `POST`. |
| `encoding` | yes | - | Encoding to be used if no encoding is found in responses (advanced parameter). |
| `headers` | yes | - | Additional headers that are sent along with the request. Format is "header=value".|
| `ignoreSSLErrors` | no | false | If set to true ignores invalid SSL certificate errors. This is potentially dangerous.|
*Note:* optional "no" means that you have to configure a value unless a default is provided and you are ok with that setting.
*Note:* Optional "no" means that you have to configure a value unless a default is provided and you are ok with that setting.
*Note:* The `BASIC_PREEMPTIVE` mode adds basic authentication headers even if the server did not request authentication.
This is dangerous and might be misused.
The option exists to be able to authenticate when the server is not sending the proper 401/Unauthorized code.
Authentication might fail if redirections are involved as headers are stripper prior to redirection.
*Note:* If you rate-limit requests by using the `delay` parameter you have to make sure that the time between two refreshes is larger than the time needed for one refresh cycle.