Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpGet.addHeader()


     * @throws IOException
     */
    @Test
    public void testRequestHeadersSingleValue() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/requestheaders"));
        getMethod.addHeader("fOo", "bAr");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertTrue(responseBody, responseBody.contains("requestheaders:"));
        assertTrue(responseBody, responseBody.contains(":fOo=[bAr]") || responseBody.contains(":foo=[bAr]"));
View Full Code Here


     * @throws IOException
     */
    @Test
    public void testRequestHeadersMultipleValues() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/requestheaders"));
        getMethod.addHeader("fOo", "bAr");
        getMethod.addHeader("abc", "xyz");
        getMethod.addHeader("fOo", "2bAr");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
View Full Code Here

     */
    @Test
    public void testRequestHeadersMultipleValues() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/requestheaders"));
        getMethod.addHeader("fOo", "bAr");
        getMethod.addHeader("abc", "xyz");
        getMethod.addHeader("fOo", "2bAr");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertTrue(responseBody, responseBody.contains("requestheaders:"));
View Full Code Here

    @Test
    public void testRequestHeadersMultipleValues() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/requestheaders"));
        getMethod.addHeader("fOo", "bAr");
        getMethod.addHeader("abc", "xyz");
        getMethod.addHeader("fOo", "2bAr");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertTrue(responseBody, responseBody.contains("requestheaders:"));
        assertTrue(responseBody, responseBody.contains(":fOo=[2bAr, bAr]") || responseBody.contains(":foo=[2bAr, bAr]"));
View Full Code Here

  private void getRest(String rightside, JiraJSONResponse response)
    throws IOException, ResponseException {

    final HttpRequestBase method = new HttpGet(URLbase + rightside);
    method.addHeader("Accept", "application/json");

    try {
      HttpResponse httpResponse = httpClient.execute(method);
      int resultCode = httpResponse.getStatusLine().getStatusCode();
      if (resultCode != 200)
View Full Code Here

  private void getRest(String rightside, JiraJSONResponse response)
    throws IOException, ResponseException {

    final HttpRequestBase method = new HttpGet(URLbase + rightside);
    method.addHeader("Accept", "application/json");

    try {
      HttpResponse httpResponse = httpClient.execute(method);
      int resultCode = httpResponse.getStatusLine().getStatusCode();
      if (resultCode != 200)
View Full Code Here

    }
   
    @Test
    public void testMappingException() throws Exception {
        HttpGet get = new HttpGet("http://localhost:" + port1 + "/CxfRsSpringConsumerTest/customerservice/customers/126");
        get.addHeader("Accept" , "application/json");
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();

        try {
            HttpResponse response = httpclient.execute(get);
            assertEquals("Get a wrong status code", 500, response.getStatusLine().getStatusCode());
View Full Code Here

    URIBuilder builder = new URIBuilder(url);
    HttpGet method = new HttpGet(builder.build());
    if (headers != null) {
      for (String headerName : headers.keySet())
        method.addHeader(headerName, headers.get(headerName));
    }
    CloseableHttpResponse response = null;
    try {
      HttpHost targetHost = new HttpHost(builder.getHost(), builder.getPort(), builder.getScheme());
View Full Code Here

     * @return
     */
    private static HttpUriRequest buildGetRequest(String url, String sessionId) {
        HttpGet request = new HttpGet(url);
        if (sessionId != null) {
            request.addHeader("Cookie", "JSESSIONID=" + sessionId);
        }

        return request;
    }

View Full Code Here

   public void testDefaultPrincipal(){

      DefaultHttpClient httpclient = new DefaultHttpClient();
      HttpResponse response;
      HttpGet httpget = new HttpGet(URL1.toString());
      httpget.addHeader("Authorization", "Basic Yzpj")//I'm not sure why this have to be here, however it does not work without it
      String text;

      try {
         response = httpclient.execute(httpget);
         text = Utils.getContent(response);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.