blob: 3581bcce4196a598602ab1c8570972be11b3a746 [file] [log] [blame]
// Copyright 2016 Twitter. All rights reserved.
//
// Licensed 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 com.twitter.heron.integration_test.core;
import java.io.IOException;
import java.text.ParseException;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
/**
* Utilities for making http calls
*/
final class HttpUtils {
private HttpUtils() { }
static int httpJsonPost(String newHttpPostUrl, String jsonData)
throws IOException, ParseException {
HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(newHttpPostUrl);
StringEntity requestEntity = new StringEntity(jsonData, ContentType.APPLICATION_JSON);
post.setEntity(requestEntity);
HttpResponse response = client.execute(post);
return response.getStatusLine().getStatusCode();
}
}