Skip to content

Commit

Permalink
Fixes #4808 - Review HttpClient Request header APIs.
Browse files Browse the repository at this point in the history
Updates after review.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed May 8, 2020
1 parent a93b2c6 commit b6c6684
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ protected Request copyRequest(HttpRequest oldRequest, URI newURI)
continue;

if (!newRequest.getHeaders().contains(field))
newRequest.header(field);
newRequest.addHeader(field);
}
return newRequest;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected void normalizeRequest(HttpRequest request)
if (version.getVersion() <= 11)
{
if (!headers.contains(HttpHeader.HOST))
request.header(getHttpDestination().getHostField());
request.addHeader(getHttpDestination().getHostField());
}

// Add content headers
Expand All @@ -172,14 +172,14 @@ protected void normalizeRequest(HttpRequest request)
if (contentType != null)
{
HttpField field = new HttpField(HttpHeader.CONTENT_TYPE, contentType);
request.header(field);
request.addHeader(field);
}
}
long contentLength = content.getLength();
if (contentLength >= 0)
{
if (!headers.contains(HttpHeader.CONTENT_LENGTH))
request.header(new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH, contentLength));
request.addHeader(new HttpField.LongValueHttpField(HttpHeader.CONTENT_LENGTH, contentLength));
}
}

Expand All @@ -194,7 +194,7 @@ protected void normalizeRequest(HttpRequest request)
if (cookies != null)
{
HttpField cookieField = new HttpField(HttpHeader.COOKIE, cookies.toString());
request.header(cookieField);
request.addHeader(cookieField);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected boolean responseHeader(HttpExchange exchange, HttpField field)
boolean process = notifier.notifyHeader(exchange.getConversation().getResponseListeners(), response, field);
if (process)
{
response.header(field);
response.addHeader(field);
HttpHeader fieldHeader = field.getHeader();
if (fieldHeader != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ public Request accept(String... accepts)
}

@Override
@Deprecated
public Request header(String name, String value)
{
if (value == null)
Expand All @@ -317,6 +318,7 @@ public Request header(String name, String value)
}

@Override
@Deprecated
public Request header(HttpHeader header, String value)
{
if (value == null)
Expand Down Expand Up @@ -382,7 +384,7 @@ public Request headers(Consumer<HttpFields.Mutable> consumer)
return this;
}

public HttpRequest header(HttpField header)
public HttpRequest addHeader(HttpField header)
{
headers.add(header);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public HttpFields getHeaders()
return headers.asImmutable();
}

public HttpResponse header(HttpField header)
public HttpResponse addHeader(HttpField header)
{
headers.add(header);
return this;
Expand Down

0 comments on commit b6c6684

Please sign in to comment.