Skip to content

Commit d74f64a

Browse files
authored
Use lowercase HTTP header field names so we are compatible with HTTP/2 (#7006)
1 parent 57d4f56 commit d74f64a

File tree

47 files changed

+142
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+142
-142
lines changed

core/src/main/java/com/cloud/network/resource/TrafficSentinelResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private DirectNetworkUsageAnswer getPublicIpBytesSentAndReceived(DirectNetworkUs
217217
String postData = "script="+URLEncoder.encode(getScript(cmd.getPublicIps(), cmd.getStart(), cmd.getEnd()), "UTF-8")+"&authenticate=basic&resultFormat=txt";
218218
HttpURLConnection con = (HttpURLConnection) trafficSentinel.openConnection();
219219
con.setRequestMethod("POST");
220-
con.setRequestProperty("Content-Length", String.valueOf(postData.length()));
220+
con.setRequestProperty("content-length", String.valueOf(postData.length()));
221221
con.setDoOutput(true);
222222

223223
//Part 2 - Write Data

core/src/main/java/com/cloud/storage/template/HttpTemplateDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ private void checkAndSetDownloadSize() {
293293
}
294294

295295
private boolean tryAndGetRemoteSize() {
296-
Header contentLengthHeader = request.getResponseHeader("Content-Length");
296+
Header contentLengthHeader = request.getResponseHeader("content-length");
297297
boolean chunked = false;
298298
long reportedRemoteSize = 0;
299299
if (contentLengthHeader == null) {

core/src/main/java/com/cloud/storage/template/S3TemplateDownloader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public long download(boolean resume, DownloadCompleteCallback callback) {
133133
}
134134

135135
// Headers
136-
Header contentLengthHeader = getMethod.getResponseHeader("Content-Length");
137-
Header contentTypeHeader = getMethod.getResponseHeader("Content-Type");
136+
Header contentLengthHeader = getMethod.getResponseHeader("content-length");
137+
Header contentTypeHeader = getMethod.getResponseHeader("content-type");
138138

139139
// Check the contentLengthHeader and transferEncodingHeader.
140140
if (contentLengthHeader == null) {

engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/TestHttp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public void testHttpclient(String templateUrl) throws IOException {
4848
long length = 0;
4949
try {
5050
HttpResponse response = client.execute(method);
51-
length = Long.parseLong(response.getFirstHeader("Content-Length").getValue());
52-
System.out.println(response.getFirstHeader("Content-Length").getValue());
51+
length = Long.parseLong(response.getFirstHeader("content-length").getValue());
52+
System.out.println(response.getFirstHeader("content-length").getValue());
5353
final File localFile = new File("/tmp/test");
5454
if (!localFile.exists()) {
5555
localFile.createNewFile();

plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private HttpResponse post(final String path, final Object obj) throws IOExceptio
202202
String url = apiURI.toString() + path;
203203
final HttpPost request = new HttpPost(url);
204204
request.setHeader(SESSION_HEADER, veeamSessionId);
205-
request.setHeader("Content-type", "application/xml");
205+
request.setHeader("content-type", "application/xml");
206206
if (StringUtils.isNotBlank(xml)) {
207207
request.setEntity(new StringEntity(xml));
208208
}

plugins/backup/veeam/src/test/java/org/apache/cloudstack/backup/veeam/VeeamClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void testBasicAuth() {
7777
public void testVeeamJobs() {
7878
wireMockRule.stubFor(get(urlMatching(".*/jobs"))
7979
.willReturn(aResponse()
80-
.withHeader("Content-Type", "application/xml")
80+
.withHeader("content-type", "application/xml")
8181
.withStatus(200)
8282
.withBody("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
8383
"<EntityReferences xmlns=\"http://www.veeam.com/ent/v1.0\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +

plugins/hypervisors/ucs/src/main/java/com/cloud/ucs/manager/UcsHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public UcsHttpClient(String ip) {
4040
public String call(String xml) {
4141
PostMethod post = new PostMethod(url);
4242
post.setRequestEntity(new StringRequestEntity(xml));
43-
post.setRequestHeader("Content-type", "text/xml");
43+
post.setRequestHeader("content-type", "text/xml");
4444
//post.setFollowRedirects(true);
4545
try {
4646
int result = client.executeMethod(post);

plugins/integrations/cloudian/src/main/java/org/apache/cloudstack/cloudian/client/CloudianClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private HttpResponse post(final String path, final Object item) throws IOExcepti
151151
final String json = mapper.writeValueAsString(item);
152152
final StringEntity entity = new StringEntity(json);
153153
final HttpPost request = new HttpPost(adminApiUrl + path);
154-
request.setHeader("Content-type", "application/json");
154+
request.setHeader("content-type", "application/json");
155155
request.setEntity(entity);
156156
final HttpResponse response = httpClient.execute(request, httpContext);
157157
checkAuthFailure(response);
@@ -163,7 +163,7 @@ private HttpResponse put(final String path, final Object item) throws IOExceptio
163163
final String json = mapper.writeValueAsString(item);
164164
final StringEntity entity = new StringEntity(json);
165165
final HttpPut request = new HttpPut(adminApiUrl + path);
166-
request.setHeader("Content-type", "application/json");
166+
request.setHeader("content-type", "application/json");
167167
request.setEntity(entity);
168168
final HttpResponse response = httpClient.execute(request, httpContext);
169169
checkAuthFailure(response);

plugins/integrations/cloudian/src/test/java/org/apache/cloudstack/cloudian/CloudianClientTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private CloudianGroup getTestGroup() {
8888
public void testRequestTimeout() {
8989
wireMockRule.stubFor(get(urlEqualTo("/group/list"))
9090
.willReturn(aResponse()
91-
.withHeader("Content-Type", "application/json")
91+
.withHeader("content-type", "application/json")
9292
.withStatus(200)
9393
.withFixedDelay(2 * timeout * 1000)
9494
.withBody("")));
@@ -131,7 +131,7 @@ public void addUserAccount() {
131131
Assert.assertTrue(result);
132132
verify(putRequestedFor(urlEqualTo("/user"))
133133
.withRequestBody(containing("userId\":\"" + user.getUserId()))
134-
.withHeader("Content-Type", equalTo("application/json")));
134+
.withHeader("content-type", equalTo("application/json")));
135135
}
136136

137137
@Test
@@ -152,7 +152,7 @@ public void listUserAccount() {
152152
final String groupId = "someGroup";
153153
wireMockRule.stubFor(get(urlPathMatching("/user?.*"))
154154
.willReturn(aResponse()
155-
.withHeader("Content-Type", "application/json")
155+
.withHeader("content-type", "application/json")
156156
.withBody("{\"userId\":\"someUser\",\"userType\":\"User\",\"fullName\":\"John Doe (jdoe)\",\"emailAddr\":\"j@doe.com\",\"address1\":null,\"address2\":null,\"city\":null,\"state\":null,\"zip\":null,\"country\":null,\"phone\":null,\"groupId\":\"someGroup\",\"website\":null,\"active\":\"true\",\"canonicalUserId\":\"b3940886468689d375ebf8747b151c37\",\"ldapEnabled\":false}")));
157157

158158
final CloudianUser user = client.listUser(userId, groupId);
@@ -166,7 +166,7 @@ public void listUserAccount() {
166166
public void listUserAccountFail() {
167167
wireMockRule.stubFor(get(urlPathMatching("/user?.*"))
168168
.willReturn(aResponse()
169-
.withHeader("Content-Type", "application/json")
169+
.withHeader("content-type", "application/json")
170170
.withBody("")));
171171

172172
final CloudianUser user = client.listUser("abc", "xyz");
@@ -178,7 +178,7 @@ public void listUserAccounts() {
178178
final String groupId = "someGroup";
179179
wireMockRule.stubFor(get(urlPathMatching("/user/list?.*"))
180180
.willReturn(aResponse()
181-
.withHeader("Content-Type", "application/json")
181+
.withHeader("content-type", "application/json")
182182
.withBody("[{\"userId\":\"someUser\",\"userType\":\"User\",\"fullName\":\"John Doe (jdoe)\",\"emailAddr\":\"j@doe.com\",\"address1\":null,\"address2\":null,\"city\":null,\"state\":null,\"zip\":null,\"country\":null,\"phone\":null,\"groupId\":\"someGroup\",\"website\":null,\"active\":\"true\",\"canonicalUserId\":\"b3940886468689d375ebf8747b151c37\",\"ldapEnabled\":false}]")));
183183

184184
final List<CloudianUser> users = client.listUsers(groupId);
@@ -191,14 +191,14 @@ public void listUserAccounts() {
191191
public void testEmptyListUsersResponse() {
192192
wireMockRule.stubFor(get(urlPathMatching("/user/list"))
193193
.willReturn(aResponse()
194-
.withHeader("Content-Type", "application/json")
194+
.withHeader("content-type", "application/json")
195195
.withStatus(204)
196196
.withBody("")));
197197
Assert.assertTrue(client.listUsers("someGroup").size() == 0);
198198

199199
wireMockRule.stubFor(get(urlPathMatching("/user"))
200200
.willReturn(aResponse()
201-
.withHeader("Content-Type", "application/json")
201+
.withHeader("content-type", "application/json")
202202
.withStatus(204)
203203
.withBody("")));
204204
Assert.assertNull(client.listUser("someUserId", "someGroupId"));
@@ -208,7 +208,7 @@ public void testEmptyListUsersResponse() {
208208
public void listUserAccountsFail() {
209209
wireMockRule.stubFor(get(urlPathMatching("/user/list?.*"))
210210
.willReturn(aResponse()
211-
.withHeader("Content-Type", "application/json")
211+
.withHeader("content-type", "application/json")
212212
.withBody("")));
213213

214214
final List<CloudianUser> users = client.listUsers("xyz");
@@ -227,7 +227,7 @@ public void updateUserAccount() {
227227
Assert.assertTrue(result);
228228
verify(postRequestedFor(urlEqualTo("/user"))
229229
.withRequestBody(containing("userId\":\"" + user.getUserId()))
230-
.withHeader("Content-Type", equalTo("application/json")));
230+
.withHeader("content-type", equalTo("application/json")));
231231
}
232232

233233
@Test
@@ -281,7 +281,7 @@ public void addGroup() {
281281
Assert.assertTrue(result);
282282
verify(putRequestedFor(urlEqualTo("/group"))
283283
.withRequestBody(containing("groupId\":\"someGroupId"))
284-
.withHeader("Content-Type", equalTo("application/json")));
284+
.withHeader("content-type", equalTo("application/json")));
285285
}
286286

287287
@Test
@@ -301,7 +301,7 @@ public void listGroup() {
301301
final String groupId = "someGroup";
302302
wireMockRule.stubFor(get(urlPathMatching("/group.*"))
303303
.willReturn(aResponse()
304-
.withHeader("Content-Type", "application/json")
304+
.withHeader("content-type", "application/json")
305305
.withBody("{\"groupId\":\"someGroup\",\"groupName\":\"/someDomain\",\"ldapGroup\":null,\"active\":\"true\",\"ldapEnabled\":false,\"ldapServerURL\":null,\"ldapUserDNTemplate\":null,\"ldapSearch\":null,\"ldapSearchUserBase\":null,\"ldapMatchAttribute\":null}")));
306306

307307
final CloudianGroup group = client.listGroup(groupId);
@@ -313,7 +313,7 @@ public void listGroup() {
313313
public void listGroupFail() {
314314
wireMockRule.stubFor(get(urlPathMatching("/group.*"))
315315
.willReturn(aResponse()
316-
.withHeader("Content-Type", "application/json")
316+
.withHeader("content-type", "application/json")
317317
.withBody("")));
318318

319319
final CloudianGroup group = client.listGroup("xyz");
@@ -325,7 +325,7 @@ public void listGroups() {
325325
final String groupId = "someGroup";
326326
wireMockRule.stubFor(get(urlEqualTo("/group/list"))
327327
.willReturn(aResponse()
328-
.withHeader("Content-Type", "application/json")
328+
.withHeader("content-type", "application/json")
329329
.withBody("[{\"groupId\":\"someGroup\",\"groupName\":\"/someDomain\",\"ldapGroup\":null,\"active\":\"true\",\"ldapEnabled\":false,\"ldapServerURL\":null,\"ldapUserDNTemplate\":null,\"ldapSearch\":null,\"ldapSearchUserBase\":null,\"ldapMatchAttribute\":null}]")));
330330

331331
final List<CloudianGroup> groups = client.listGroups();
@@ -338,7 +338,7 @@ public void listGroups() {
338338
public void listGroupsFail() {
339339
wireMockRule.stubFor(get(urlEqualTo("/group/list"))
340340
.willReturn(aResponse()
341-
.withHeader("Content-Type", "application/json")
341+
.withHeader("content-type", "application/json")
342342
.withBody("")));
343343

344344
final List<CloudianGroup> groups = client.listGroups();
@@ -349,7 +349,7 @@ public void listGroupsFail() {
349349
public void testEmptyListGroupResponse() {
350350
wireMockRule.stubFor(get(urlEqualTo("/group/list"))
351351
.willReturn(aResponse()
352-
.withHeader("Content-Type", "application/json")
352+
.withHeader("content-type", "application/json")
353353
.withStatus(204)
354354
.withBody("")));
355355

@@ -358,7 +358,7 @@ public void testEmptyListGroupResponse() {
358358

359359
wireMockRule.stubFor(get(urlPathMatching("/group"))
360360
.willReturn(aResponse()
361-
.withHeader("Content-Type", "application/json")
361+
.withHeader("content-type", "application/json")
362362
.withStatus(204)
363363
.withBody("")));
364364
Assert.assertNull(client.listGroup("someGroup"));
@@ -376,7 +376,7 @@ public void updateGroup() {
376376
Assert.assertTrue(result);
377377
verify(postRequestedFor(urlEqualTo("/group"))
378378
.withRequestBody(containing("groupId\":\"" + group.getGroupId()))
379-
.withHeader("Content-Type", equalTo("application/json")));
379+
.withHeader("content-type", equalTo("application/json")));
380380
}
381381

382382
@Test

plugins/integrations/prometheus/src/main/java/org/apache/cloudstack/metrics/PrometheusExporterServerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void handle(final HttpExchange httpExchange) throws IOException {
5757
response = prometheusExporter.getMetrics();
5858
responseCode = 200;
5959
}
60-
httpExchange.getResponseHeaders().set("Content-Type", "text/plain");
60+
httpExchange.getResponseHeaders().set("content-type", "text/plain");
6161
httpExchange.sendResponseHeaders(responseCode, response.length());
6262
final OutputStream os = httpExchange.getResponseBody();
6363
os.write(response.getBytes());

0 commit comments

Comments
 (0)