Code example for HttpRequestBase

Methods: addHeader

0
         
        public HttpRequestBase create(){
            String serverHost = getHostServer();
//            String requestURL = serverHost + mCommand + "?" + encodeParameters(mParams); 
            final String fileName = mParams.remove(API_PARAM_FILE);
 
            String requestURL = serverHost + "?" + encodeParameters(mParams);
 
            BLog.d("Server request: " + requestURL);
                         
            HttpRequestBase request = null;
            if(GET.equalsIgnoreCase(mMethod) && null == fileName){
                request = new HttpGet(requestURL);
            } else if(POST.equalsIgnoreCase(mMethod) || null != fileName) {
                request = new HttpPost(requestURL);
                if (null != fileName) {
                    MultipartEntity multipart = new MultipartEntity();
//                    multipart.addPart("method", new StringBody(mMethod)); 
                    multipart.addPart(API_PARAM_FILE, new FileBody(new File(fileName)));
//                    HttpClient client = new DefaultHttpClient(); 
                    ((HttpPost)request).setEntity(multipart);