Skip to content

Commit 655a3f1

Browse files
authored
feat: add CharSequence overloads for putHeader methods in HttpRequest
1 parent 139e274 commit 655a3f1

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

vertx-web-client/src/main/java/io/vertx/ext/web/client/HttpRequest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ public interface HttpRequest<T> {
182182
@Fluent
183183
HttpRequest<T> putHeader(String name, String value);
184184

185+
/**
186+
* Configure the request to set a new HTTP header using CharSequence.
187+
* <p>
188+
* This is an overload of {@link #putHeader(String, String)} that accepts CharSequence parameters.
189+
*
190+
* @param name the header name
191+
* @param value the header value
192+
* @return a reference to this, so the API can be used fluently
193+
*/
194+
@Fluent
195+
@GenIgnore(GenIgnore.PERMITTED_TYPE)
196+
HttpRequest<T> putHeader(CharSequence name, CharSequence value);
197+
185198
/**
186199
* Configure the request to set a new HTTP header with multiple values.
187200
*
@@ -193,6 +206,19 @@ public interface HttpRequest<T> {
193206
@GenIgnore(GenIgnore.PERMITTED_TYPE)
194207
HttpRequest<T> putHeader(String name, Iterable<String> value);
195208

209+
/**
210+
* Configure the request to set a new HTTP header with multiple values using CharSequence.
211+
* <p>
212+
* This is an overload of {@link #putHeader(String, Iterable)} that accepts CharSequence parameters.
213+
*
214+
* @param name the header name
215+
* @param value the header value
216+
* @return a reference to this, so the API can be used fluently
217+
*/
218+
@Fluent
219+
@GenIgnore(GenIgnore.PERMITTED_TYPE)
220+
HttpRequest<T> putHeader(CharSequence name, Iterable<CharSequence> value);
221+
196222
/**
197223
* @return The HTTP headers
198224
*/

vertx-web-client/src/main/java/io/vertx/ext/web/client/impl/HttpRequestImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,24 @@ public HttpRequest<T> putHeader(String name, String value) {
231231
return this;
232232
}
233233

234+
@Override
235+
public HttpRequest<T> putHeader(CharSequence name, CharSequence value) {
236+
headers().set(name, value);
237+
return this;
238+
}
239+
234240
@Override
235241
public HttpRequest<T> putHeader(String name, Iterable<String> value) {
236242
headers().set(name, value);
237243
return this;
238244
}
239245

246+
@Override
247+
public HttpRequest<T> putHeader(CharSequence name, Iterable<CharSequence> value) {
248+
headers().set(name, value);
249+
return this;
250+
}
251+
240252
@Override
241253
public MultiMap headers() {
242254
if (headers == null) {

0 commit comments

Comments
 (0)