Package org.openhab.core.io.net.http
Class HttpRequestBuilder
java.lang.Object
org.openhab.core.io.net.http.HttpRequestBuilder
Builder class to construct http requests
- Author:
- Martin van Wingerden - Initial contribution
- 
Method SummaryModifier and TypeMethodDescriptionExecutes the build requeststatic HttpRequestBuilderConstruct an http request builder to get data from anurlstatic HttpRequestBuilderConstruct an http request builder to post data to aurlwithContent(String content) Add content to this requestwithContent(String content, String contentType) Add content with a specific type to this requestwithHeader(String header, String value) Add an additional header to the requestwithTimeout(Duration timeout) Add a timeout for this request
- 
Method Details- 
getFromConstruct an http request builder to get data from anurl- Parameters:
- url- to fetch the data from
- Returns:
- a request builder to construct and complete the request
 
- 
postToConstruct an http request builder to post data to aurl- Parameters:
- url- to post data to
- Returns:
- a request builder to construct and complete the request
 
- 
withTimeoutAdd a timeout for this request- Parameters:
- timeout- the timeout for this http request as a- Duration
- Returns:
- a request builder to construct and complete the request
 
- 
withHeaderAdd an additional header to the request- Parameters:
- header- name of the header, eg. Content-Type
- value- value of the header, eg. "application/json"
- Returns:
- a request builder to construct and complete the request
 
- 
withContentAdd content to this request- Parameters:
- content- a string containing the data to be pushed to the- url
- Returns:
- a request builder to construct and complete the request
 
- 
withContentAdd content with a specific type to this request- Parameters:
- content- a string containing the data to be pushed to the- url
- contentType- the content type of the given- content
- Returns:
- a request builder to construct and complete the request
 
- 
getContentAsStringExecutes the build request- Returns:
- the response body or nullwhen the request went wrong
- Throws:
- IOException- when the request execution failed, timed out or it was interrupted
 
 
-