use of org.apache.http.message.BasicHeader in project hbase by apache.
the class TestGzipFilter method testScannerResultCodes.
void testScannerResultCodes() throws Exception {
Header[] headers = new Header[3];
headers[0] = new BasicHeader("Content-Type", Constants.MIMETYPE_XML);
headers[1] = new BasicHeader("Accept", Constants.MIMETYPE_JSON);
headers[2] = new BasicHeader("Accept-Encoding", "gzip");
Response response = client.post("/" + TABLE + "/scanner", headers, "<Scanner/>".getBytes());
assertEquals(response.getCode(), 201);
String scannerUrl = response.getLocation();
assertNotNull(scannerUrl);
response = client.get(scannerUrl);
assertEquals(response.getCode(), 200);
response = client.get(scannerUrl);
assertEquals(response.getCode(), 204);
}
use of org.apache.http.message.BasicHeader in project hbase by apache.
the class Client method get.
/**
* Send a GET request
* @param cluster the cluster definition
* @param path the path or URI
* @param accept Accept header value
* @return a Response object with response detail
* @throws IOException
*/
public Response get(Cluster cluster, String path, String accept) throws IOException {
Header[] headers = new Header[1];
headers[0] = new BasicHeader("Accept", accept);
return get(cluster, path, headers);
}
use of org.apache.http.message.BasicHeader in project hbase by apache.
the class Client method put.
/**
* Send a PUT request
* @param cluster the cluster definition
* @param path the path or URI
* @param contentType the content MIME type
* @param content the content bytes
* @param extraHdr additional Header to send
* @return a Response object with response detail
* @throws IOException for error
*/
public Response put(Cluster cluster, String path, String contentType, byte[] content, Header extraHdr) throws IOException {
int cnt = extraHdr == null ? 1 : 2;
Header[] headers = new Header[cnt];
headers[0] = new BasicHeader("Content-Type", contentType);
if (extraHdr != null) {
headers[1] = extraHdr;
}
return put(cluster, path, headers, content);
}
use of org.apache.http.message.BasicHeader in project hbase by apache.
the class Client method post.
/**
* Send a POST request
* @param cluster the cluster definition
* @param path the path or URI
* @param contentType the content MIME type
* @param content the content bytes
* @return a Response object with response detail
* @throws IOException for error
*/
public Response post(Cluster cluster, String path, String contentType, byte[] content) throws IOException {
Header[] headers = new Header[1];
headers[0] = new BasicHeader("Content-Type", contentType);
return post(cluster, path, headers, content);
}
use of org.apache.http.message.BasicHeader in project hbase by apache.
the class TestRemoteTable method testResponse.
/**
* Test a some methods of class Response.
*/
@Test
public void testResponse() {
Response response = new Response(200);
assertEquals(200, response.getCode());
Header[] headers = new Header[2];
headers[0] = new BasicHeader("header1", "value1");
headers[1] = new BasicHeader("header2", "value2");
response = new Response(200, headers);
assertEquals("value1", response.getHeader("header1"));
assertFalse(response.hasBody());
response.setCode(404);
assertEquals(404, response.getCode());
headers = new Header[2];
headers[0] = new BasicHeader("header1", "value1.1");
headers[1] = new BasicHeader("header2", "value2");
response.setHeaders(headers);
assertEquals("value1.1", response.getHeader("header1"));
response.setBody(Bytes.toBytes("body"));
assertTrue(response.hasBody());
}
Aggregations