Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ Import-Package: com.google.gson,\
org.apache.commons.logging,\
org.apache.hc.core5.http,\
org.apache.hc.core5.http.io.entity,\
org.apache.hc.core5.http.io.support,\
org.apache.hc.core5.http.message,\
org.apache.hc.core5.http.protocol,\
org.apache.hc.core5.http.ssl,\
org.apache.hc.core5.net,\
org.apache.hc.core5.util,\
org.apache.hc.client5.http,\
org.apache.hc.client5.http.auth,\
org.apache.hc.client5.http.classic.methods,\
org.apache.hc.client5.http.config,\
org.apache.hc.client5.http.cookie,\
org.apache.hc.client5.http.entity,\
org.apache.hc.client5.http.entity.mime,\
org.apache.hc.client5.http.impl,\
org.apache.hc.client5.http.impl.auth,\
org.apache.hc.client5.http.impl.classic,\
org.apache.hc.client5.http.impl.io,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public enum ContentType {
APPLICATION_FORM_URLENCODED(org.apache.hc.core5.http.ContentType.APPLICATION_FORM_URLENCODED),
TEXT_PLAIN(org.apache.hc.core5.http.ContentType.TEXT_PLAIN),
TEXT_HTML(org.apache.hc.core5.http.ContentType.TEXT_HTML),
TEXT_MARKDOWN(org.apache.hc.core5.http.ContentType.TEXT_MARKDOWN),
TEXT_EVENT_STREAM(org.apache.hc.core5.http.ContentType.TEXT_EVENT_STREAM),
TEXT_XML(org.apache.hc.core5.http.ContentType.TEXT_XML),
RDF_XML("application/rdf+xml"),
SOAP_XML("application/soap+xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@
@ValidAnnotatedFields({ IHttpClient.class })
public @interface HttpClient {

/**
* The length of time a connection or response will timeout (in milliseconds). Optional.
*/
int timeout() default 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,28 @@ HttpClientResponse<String> postXML(String url, String xml)
*/
HttpClientResponse<String> postText(String url, String text) throws HttpClientException;

/**
* Issue an HTTP POST to the provided URL, sending form-encoded data
* and receiving a {@link String} in the response.
*
* <p>
* This is a convenience method for posting form data (e.g., login credentials).
* The data is encoded as application/x-www-form-urlencoded, which is the standard
* format for HTML form submissions.
* </p>
*
* <p>
* This method is commonly used for form-based authentication where credentials
* are posted as form fields (e.g., j_username, j_password for Java EE security).
* </p>
*
* @param url - URL path
* @param fields - Form fields as key-value pairs
* @return - {@link HttpClientResponse} with a {@link String} content type
* @throws HttpClientException if the request fails
*/
HttpClientResponse<String> postForm(String url, Map<String, String> fields) throws HttpClientException;

/**
* Issue an HTTP PUT to the provided URL, sending the provided {@link String}
* and receiving a {@link String} in the response.
Expand Down Expand Up @@ -412,6 +434,24 @@ Object postForm(String path, Map<String, String> queryParams, HashMap<String, St
*/
void addOkResponseCode(int responseCode);

/**
* Set the socket timeout in seconds.
* This is the timeout for waiting for data after connection is established.
* Must be called before {@link #build()}.
*
* @param seconds - timeout in seconds
*/
void setSocketTimeout(int seconds);

/**
* Set the connection timeout in seconds.
* This is the timeout for establishing the connection.
* Must be called before {@link #build()}.
*
* @param seconds - timeout in seconds
*/
void setConnectTimeout(int seconds);

/**
* Build the client
*
Expand Down Expand Up @@ -508,5 +548,18 @@ IHttpClient setupClientAuth(KeyStore keyStore, String password)
* @param host
*/
void setURI(URI host);

/**
* Clear the cookie store
*/
void clearCookies();

/**
* Set TLS versions required.
*
* @param tlsVersions
* TLS versions
*/
Comment thread
eamansour marked this conversation as resolved.
void setTlsVersions(TLS[] tlsVersions);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright contributors to the Galasa project
*
* SPDX-License-Identifier: EPL-2.0
*/
package dev.galasa.http;

public enum TLS {

v1_0(org.apache.hc.core5.http.ssl.TLS.V_1_0),
v1_1(org.apache.hc.core5.http.ssl.TLS.V_1_1),
v1_2(org.apache.hc.core5.http.ssl.TLS.V_1_2),
v1_3(org.apache.hc.core5.http.ssl.TLS.V_1_3);


private final org.apache.hc.core5.http.ssl.TLS tls;

TLS(org.apache.hc.core5.http.ssl.TLS tls) {
this.tls = tls;
}

public org.apache.hc.core5.http.ssl.TLS getTls() {
return tls;
}

}
Loading
Loading