HttpClient3.1设置header信息

     HttpClient client = new HttpClient();

        GetMethod get = new GetMethod(URL);

        get.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");

        get.setRequestHeader("Authorization", base64_auth_string);

        get.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");  

        

       对于PostMethod设置方式与GetMethod方式一样。

 

你可能感兴趣的:(httpclient)