mirror of
https://github.com/esphome/esphome.git
synced 2025-09-02 03:12:20 +01:00
[http_request] Implement for host platform (#8040)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
substitutions:
|
||||
verify_ssl: "true"
|
||||
<<: !include http_request.yaml
|
||||
|
||||
wifi:
|
||||
ssid: MySSID
|
||||
|
46
tests/components/http_request/http_request.yaml
Normal file
46
tests/components/http_request/http_request.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
substitutions:
|
||||
verify_ssl: "true"
|
||||
|
||||
network:
|
||||
|
||||
esphome:
|
||||
on_boot:
|
||||
then:
|
||||
- http_request.get:
|
||||
url: https://esphome.io
|
||||
request_headers:
|
||||
Content-Type: application/json
|
||||
on_error:
|
||||
logger.log: "Request failed"
|
||||
on_response:
|
||||
then:
|
||||
- logger.log:
|
||||
format: "Response status: %d, Duration: %lu ms"
|
||||
args:
|
||||
- response->status_code
|
||||
- (long) response->duration_ms
|
||||
- http_request.post:
|
||||
url: https://esphome.io
|
||||
request_headers:
|
||||
Content-Type: application/json
|
||||
json:
|
||||
key: value
|
||||
- http_request.send:
|
||||
method: PUT
|
||||
url: https://esphome.io
|
||||
request_headers:
|
||||
Content-Type: application/json
|
||||
body: "Some data"
|
||||
|
||||
http_request:
|
||||
useragent: esphome/tagreader
|
||||
timeout: 10s
|
||||
verify_ssl: ${verify_ssl}
|
||||
|
||||
script:
|
||||
- id: does_not_compile
|
||||
parameters:
|
||||
api_url: string
|
||||
then:
|
||||
- http_request.get:
|
||||
url: "http://google.com"
|
7
tests/components/http_request/test.host.yaml
Normal file
7
tests/components/http_request/test.host.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
substitutions:
|
||||
verify_ssl: "true"
|
||||
http_request:
|
||||
# Just a file we can be sure exists
|
||||
ca_certificate_path: /etc/passwd
|
||||
|
||||
<<: !include http_request.yaml
|
Reference in New Issue
Block a user