use of org.apache.http.message.BasicHeader in project pentaho-kettle by pentaho.
the class WebServiceTest method getLocationFrom.
@Test
public void getLocationFrom() {
HttpPost postMethod = mock(HttpPost.class);
Header locationHeader = new BasicHeader(LOCATION_HEADER, TEST_URL);
doReturn(locationHeader).when(postMethod).getFirstHeader(LOCATION_HEADER);
assertEquals(TEST_URL, WebService.getLocationFrom(postMethod));
}
use of org.apache.http.message.BasicHeader in project coprhd-controller by CoprHD.
the class NTLMDecryptedEntity method buildContentTypeHeader.
/**
* Builds the content type header that would have existed in a decrypted message.
*
* @param type
* the original content type
* @param encoding
* the original charset
*
* @return the new content type header
*/
private Header buildContentTypeHeader(String type, String encoding) {
NameValuePair[] nvps = new NameValuePair[] { new BasicNameValuePair(NTLMConstants.CHARSET, encoding) };
BasicHeaderElement elem = new BasicHeaderElement(type, null, nvps);
return new BasicHeader(HttpHeaders.CONTENT_TYPE, BasicHeaderValueFormatter.formatHeaderElement(elem, false, null));
}
use of org.apache.http.message.BasicHeader in project TaEmCasa by Dionen.
the class HttpHeaderParserTest method parseCaseInsensitive.
@Test
public void parseCaseInsensitive() {
long now = System.currentTimeMillis();
Header[] headersArray = new Header[5];
headersArray[0] = new BasicHeader("eTAG", "Yow!");
headersArray[1] = new BasicHeader("DATE", rfc1123Date(now));
headersArray[2] = new BasicHeader("expires", rfc1123Date(now + ONE_HOUR_MILLIS));
headersArray[3] = new BasicHeader("cache-control", "public, max-age=86400");
headersArray[4] = new BasicHeader("content-type", "text/plain");
Map<String, String> headers = BasicNetwork.convertHeaders(headersArray);
NetworkResponse response = new NetworkResponse(0, null, headers, false);
Cache.Entry entry = HttpHeaderParser.parseCacheHeaders(response);
assertNotNull(entry);
assertEquals("Yow!", entry.etag);
assertEqualsWithin(now + ONE_DAY_MILLIS, entry.ttl, ONE_MINUTE_MILLIS);
assertEquals(entry.softTtl, entry.ttl);
assertEquals("ISO-8859-1", HttpHeaderParser.parseCharset(headers));
}
use of org.apache.http.message.BasicHeader in project gerrit by GerritCodeReview.
the class RestSession method postWithHeader.
public RestResponse postWithHeader(String endPoint, Object content, Header header) throws IOException {
Request post = Request.Post(getUrl(endPoint));
if (header != null) {
post.addHeader(header);
}
if (content != null) {
post.addHeader(new BasicHeader("Content-Type", "application/json"));
post.body(new StringEntity(OutputFormat.JSON_COMPACT.newGson().toJson(content), UTF_8));
}
return execute(post);
}
use of org.apache.http.message.BasicHeader in project gerrit by GerritCodeReview.
the class RestSession method putWithHeader.
public RestResponse putWithHeader(String endPoint, Header header, Object content) throws IOException {
Request put = Request.Put(getUrl(endPoint));
if (header != null) {
put.addHeader(header);
}
if (content != null) {
put.addHeader(new BasicHeader("Content-Type", "application/json"));
put.body(new StringEntity(OutputFormat.JSON_COMPACT.newGson().toJson(content), UTF_8));
}
return execute(put);
}
Aggregations