Class: OpenHAB::Core::Actions::HTTP
- Inherits:
-
Object
- Object
- OpenHAB::Core::Actions::HTTP
- Defined in:
- lib/openhab/core/actions/http.rb
Overview
The HTTP actions allow you to send HTTP requests and receive the response.
Class Method Summary collapse
-
.send_http_delete_request(url, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP DELETE request and returns the result as a String.
-
.send_http_get_request(url, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP GET request and returns the result as a String.
-
.send_http_post_request(url, content_type = nil, content = nil, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP POST request and returns the result as a String.
-
.send_http_put_request(url, content_type = nil, content = nil, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP PUT request and returns the result as a String.
Class Method Details
.send_http_delete_request(url, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP DELETE request and returns the result as a String.
86 87 88 89 90 91 |
# File 'lib/openhab/core/actions/http.rb', line 86 def send_http_delete_request(url, headers: {}, timeout: nil) timeout ||= 1_000 timeout = timeout.to_millis if timeout.is_a?(Duration) sendHttpDeleteRequest(url, headers.transform_keys(&:to_s), timeout) end |
.send_http_get_request(url, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP GET request and returns the result as a String.
30 31 32 33 34 35 |
# File 'lib/openhab/core/actions/http.rb', line 30 def send_http_get_request(url, headers: {}, timeout: nil) timeout ||= 5_000 timeout = timeout.to_millis if timeout.is_a?(Duration) sendHttpGetRequest(url, headers.transform_keys(&:to_s), timeout) end |
.send_http_post_request(url, content_type = nil, content = nil, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP POST request and returns the result as a String.
68 69 70 71 72 73 |
# File 'lib/openhab/core/actions/http.rb', line 68 def send_http_post_request(url, content_type = nil, content = nil, headers: {}, timeout: nil) timeout ||= 1_000 timeout = timeout.to_millis if timeout.is_a?(Duration) sendHttpPostRequest(url, content_type, content, headers.transform_keys(&:to_s), timeout) end |
.send_http_put_request(url, content_type = nil, content = nil, headers: {}, timeout: nil) ⇒ String?
Sends an HTTP PUT request and returns the result as a String.
49 50 51 52 53 54 |
# File 'lib/openhab/core/actions/http.rb', line 49 def send_http_put_request(url, content_type = nil, content = nil, headers: {}, timeout: nil) timeout ||= 1_000 timeout = timeout.to_millis if timeout.is_a?(Duration) sendHttpPutRequest(url, content_type, content, headers.transform_keys(&:to_s), timeout) end |