Package ch.k43.util
Klasse KHTTPClient
java.lang.Object
ch.k43.util.KHTTPClient
Support basic HTTP or HTTPS client transactions.
Note: The request headers "Date", "User-Agent", "Host" and "Content-Length" are automatically added.
Example: HTTPClient httpClient = New HTTPClient(); if (!httpClient.get("https://google.com")) { KLog.error("HTTPS transaction failed - " + httpGet.getLastError()); ... } String hostData = httpClient.getResponseDataAsString():
-
Konstruktorübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungboolean
delete
(String argURL, Properties argHeaders) Execute HTTP DELETE request.boolean
Execute HTTP GET request.boolean
get
(String argURL, Properties argHeaders) Execute HTTP GET request and set HTTP request headers.Return last error message.int
Return last HTTP response code.byte[]
Return HTTP response data.Return HTTP response data.Return last HTTP response headers.int
Get response time of last HTTP request in milliseconds.boolean
head
(String argURL, Properties argHeaders) Execute HTTP HEAD request.boolean
options
(String argURL, Properties argHeaders) Execute HTTP OPTIONS request.boolean
patch
(String argURL, Properties argHeaders, byte[] argPayload) Execute HTTP PATCH request.boolean
patch
(String argURL, Properties argHeaders, String argPayload) Execute HTTP PATCH request.boolean
post
(String argURL, Properties argHeaders, byte[] argPayload) Execute HTTP POST request.boolean
post
(String argURL, Properties argHeaders, String argPayload) Execute HTTP POST request.boolean
put
(String argURL, Properties argHeaders, byte[] argPayload) Execute HTTP PUT request.boolean
put
(String argURL, Properties argHeaders, String argPayload) Execute HTTP PUT request.toString()
String representation of object.
-
Konstruktordetails
-
KHTTPClient
public KHTTPClient()Class constructor.
-
-
Methodendetails
-
delete
Execute HTTP DELETE request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or null- Gibt zurück:
- True (if HTTP return code 200), else false
- Seit:
- 2024.05.22
-
get
Execute HTTP GET request.- Parameter:
argURL
- URL to connect- Gibt zurück:
- True if HTTP return code is 200, false otherwise
-
get
Execute HTTP GET request and set HTTP request headers.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or null- Gibt zurück:
- True if HTTP return code is 200 else false
-
getLastError
Return last error message.- Gibt zurück:
- Last error message or null
-
getResponseCode
public int getResponseCode()Return last HTTP response code.- Gibt zurück:
- Last HTTP response code
-
getResponseDataAsBytes
public byte[] getResponseDataAsBytes()Return HTTP response data.- Gibt zurück:
- byte[] HTTP response data
-
getResponseDataAsString
Return HTTP response data.- Gibt zurück:
- HTTP response data or null
-
getResponseHeaders
Return last HTTP response headers.- Gibt zurück:
- HTTP response headers
-
getResponseTimeMs
public int getResponseTimeMs()Get response time of last HTTP request in milliseconds.- Gibt zurück:
- HTTP response time in milliseconds
-
head
Execute HTTP HEAD request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or null- Gibt zurück:
- True (if HTTP return code 200), else false
-
options
Execute HTTP OPTIONS request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or null- Gibt zurück:
- True (if HTTP return code 200), else false
- Seit:
- 2024.05.22
-
patch
Execute HTTP PATCH request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or nullargPayload
- Data to be sent with PATCH request- Gibt zurück:
- True (if HTTP return code 200), else false
- Seit:
- 2024.05.22
-
patch
Execute HTTP PATCH request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or nullargPayload
- Data to be sent with PATCH request- Gibt zurück:
- True (if HTTP return code 200), else false
- Seit:
- 2024.05.22
-
post
Execute HTTP POST request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or nullargPayload
- Data to be sent with POST request- Gibt zurück:
- True (if HTTP return code 200), else false
-
post
Execute HTTP POST request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or nullargPayload
- Data to be sent with POST request- Gibt zurück:
- True (if HTTP return code 200), else false
-
put
Execute HTTP PUT request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or nullargPayload
- Data to be sent with PUT request- Gibt zurück:
- True (if HTTP return code 200), else false
- Seit:
- 2024.05.22
-
put
Execute HTTP PUT request.- Parameter:
argURL
- URL to connectargHeaders
- Additional HTTP request headers or nullargPayload
- Data to be sent with PUT request- Gibt zurück:
- True (if HTTP return code 200), else false
- Seit:
- 2024.05.22
-
toString
String representation of object.
-