Skip to content

Commit 1b2d228

Browse files
authored
Add HttpWaitStrategy#withMethod (#3533)
1 parent d60d490 commit 1b2d228

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

core/src/main/java/org/testcontainers/containers/wait/strategy/HttpWaitStrategy.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class HttpWaitStrategy extends AbstractWaitStrategy {
3535
private static final String AUTH_BASIC = "Basic ";
3636

3737
private String path = "/";
38+
private String method = "GET";
3839
private Set<Integer> statusCodes = new HashSet<>();
3940
private boolean tlsEnabled;
4041
private String username;
@@ -97,6 +98,17 @@ public HttpWaitStrategy usingTls() {
9798
return this;
9899
}
99100

101+
/**
102+
* Indicates the HTTP method to use (<code>GET</code> by default).
103+
*
104+
* @param method the HTTP method.
105+
* @return this
106+
*/
107+
public HttpWaitStrategy withMethod(String method) {
108+
this.method = method;
109+
return this;
110+
}
111+
100112
/**
101113
* Authenticate with HTTP Basic Authorization credentials.
102114
*
@@ -167,7 +179,7 @@ protected void waitUntilReady() {
167179
connection.setUseCaches(false);
168180
}
169181

170-
connection.setRequestMethod("GET");
182+
connection.setRequestMethod(method);
171183
connection.connect();
172184

173185
log.trace("Get response code {}", connection.getResponseCode());

0 commit comments

Comments
 (0)