Package org.apache.http.client.methods

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


            if(hasBody) req.addHeader("Content-type", "application/octet-stream");
            else req.addHeader("Content-type", "application/x-www-form-urlencoded; charset="+charset);
          }
          else {
            if(hasBody)
              req.addHeader("Content-type", "text/html; charset="+charset );
          }
        }
       
       
        // set User Agent
View Full Code Here


            //else if(multi!=null)multi.addParameter(param.getName(),param.getValueAsString());
          }
        // CGI
          else if(type.equals("cgi")) {
            if(param.getEncoded())
              req.addHeader(
                  urlenc(param.getName(),charset),
                  urlenc(param.getValueAsString(),charset));
                    else
                        req.addHeader(param.getName(),param.getValueAsString());
          }
View Full Code Here

            if(param.getEncoded())
              req.addHeader(
                  urlenc(param.getName(),charset),
                  urlenc(param.getValueAsString(),charset));
                    else
                        req.addHeader(param.getName(),param.getValueAsString());
          }
            // Header
                else if(type.startsWith("head")) {
                  if(param.getName().equalsIgnoreCase("content-type")) hasContentType=true;
                 
View Full Code Here

                  if(param.getName().equalsIgnoreCase("Content-Length")) {}
                  else if(param.getName().equalsIgnoreCase("Accept-Encoding")) {
                    acceptEncoding.append(headerValue(param.getValueAsString()));
                    acceptEncoding.append(", ");
                  }
                  else req.addHeader(param.getName(),headerValue(param.getValueAsString()));
                }
        // Cookie
          else if(type.equals("cookie")) {
            HTTPEngine4Impl.addCookie(client,host,param.getName(),param.getValueAsString(),"/",charset);
          }
View Full Code Here

            String cs=charset;
            if(ct!=null && !StringUtil.isEmpty(ct.getCharset(),true)) cs=ct.getCharset();
           
            hasBody=true;
            hasContentType=true;
            req.addHeader("Content-type", mt+"; charset="+cs);
              if(eem==null)throw new ApplicationException("type xml is only supported for type post and put");
              HTTPEngine4Impl.setBody(eem, param.getValueAsString(),mt,cs);
          }
        // Body
          else if(type.equals("body")) {
View Full Code Here

        if(hasBody && hasForm)
          throw new ApplicationException("mixing httpparam  type file/formfield and body/XML is not allowed");
     
        if(!hasContentType) {
          if(isBinary) {
            if(hasBody) req.addHeader("Content-type", "application/octet-stream");
            else req.addHeader("Content-type", "application/x-www-form-urlencoded; charset="+charset);
          }
          else {
            if(hasBody)
              req.addHeader("Content-type", "text/html; charset="+charset );
View Full Code Here

          throw new IOException("Method " + method
              + " not supported on internal tunneling proxy");
        }

        for (BasicHeader header : tunneledHeaders) {
          tunnelRequest.addHeader(header);
        }

        // TODO: Does this throws interrupted exception? Does this
        // recognize thread interruption? Tests must be made
        HttpResponse tunnelResponse = httpClient.execute(tunnelRequest);
View Full Code Here

    // Add AuthCache to the execution context
    HttpClientContext localContext = HttpClientContext.create();
    localContext.setAuthCache(authCache);

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

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

    // Add AuthCache to the execution context
    HttpClientContext localContext = HttpClientContext.create();
    localContext.setAuthCache(authCache);

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

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

                continue;
           
            for (Enumeration enumHeaderValues = request.getHeaders(headerName); enumHeaderValues.hasMoreElements(); )
            {
                String headerValue = (String) enumHeaderValues.nextElement();
                httpRequest.addHeader(headerName, headerValue);
            }
        }
       
        Map<String, String> defaultRequestHeaders = proxyPathMapper.getDefaultRequestHeaders();
       
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.