Code example for HttpRequestBase

Methods: addHeader

0
    public void setURI(URI uri) {
        mRequest.setURI(uri);
    } 
 
    public void addHeader(String name, String value){
        mRequest.addHeader(name, value);
    } 
 
    public void setContent(String content, String contentType) {
        mRequest.setHeader("Content-Type", contentType);
        //mRequest.setHeader("Content-Length", String.valueOf(content.length())); 
        try { 
            ((HttpPost)mRequest).setEntity(new StringEntity(content, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
            Log.e(CLASS_TAG, "Problem encoding: "+content);
        } 
    } 
 
    public void run() { 
        mHandler.sendMessage(
                Message.obtain(mHandler, APIHandler.START, new APIResponse(this, null)));