afedulov commented on code in PR #22816:
URL: https://github.com/apache/flink/pull/22816#discussion_r1253253546
##########
flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java:
##########
@@ -411,30 +413,31 @@ private static Request createRequest(
String targetUrl,
HttpMethod httpMethod,
ByteBuf jsonPayload,
- Collection<FileUpload> fileUploads)
+ Collection<FileUpload> fileUploads,
+ Collection<HttpHeader> customHeaders)
throws IOException {
if (fileUploads.isEmpty()) {
HttpRequest httpRequest =
new DefaultFullHttpRequest(
HttpVersion.HTTP_1_1, httpMethod, targetUrl,
jsonPayload);
- httpRequest
- .headers()
- .set(HttpHeaderNames.HOST, targetAddress)
+ HttpHeaders headers = httpRequest.headers();
+ headers.set(HttpHeaderNames.HOST, targetAddress)
.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE)
.add(HttpHeaderNames.CONTENT_LENGTH,
jsonPayload.capacity())
.add(HttpHeaderNames.CONTENT_TYPE,
RestConstants.REST_CONTENT_TYPE);
+ customHeaders.forEach(ch -> headers.add(ch.getName(),
ch.getValue()));
return new SimpleRequest(httpRequest);
} else {
HttpRequest httpRequest =
new DefaultFullHttpRequest(HttpVersion.HTTP_1_1,
httpMethod, targetUrl);
- httpRequest
- .headers()
- .set(HttpHeaderNames.HOST, targetAddress)
+ HttpHeaders headers = httpRequest.headers();
+ headers.set(HttpHeaderNames.HOST, targetAddress)
.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.CLOSE);
+ customHeaders.forEach(ch -> headers.set(ch.getName(),
ch.getValue()));
Review Comment:
addressed
##########
flink-runtime/src/main/java/org/apache/flink/runtime/rest/HttpHeader.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.rest;
+
+import java.util.Objects;
+
+/** Represents an HTTP header with a name and a value. */
+public class HttpHeader {
+
+ /** The name of the HTTP header. */
+ private final String name;
+
+ /** The value of the HTTP header. */
+ private final String value;
+
+ /**
+ * Constructs an {@code HttpHeader} object with the specified name and
value.
+ *
+ * @param name the name of the HTTP header
+ * @param value the value of the HTTP header
+ */
+ public HttpHeader(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Returns the name of this HTTP header.
+ *
+ * @return the name of this HTTP header
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns the value of this HTTP header.
+ *
+ * @return the value of this HTTP header
+ */
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return "HttpHeader{" + "name='" + name + '\'' + ", value='" + value +
'\'' + '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
Review Comment:
addressed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]