최근에 HTTPPost로 요청을 처리 중이고 Content-Type : application/json으로 헤더를 설정해야하며 기본 인증이 필요합니다. 여기에 있습니다 :Android java http with authentication remove 콘텐츠 유형
A :
httpPost.setHeader("Content-type","application/json");
String authenData = String.format(Locale.getDefault(), "%s:%s", "[email protected]", "xxx");
String base64EncodedCredentials = Base64.encodeToString(authenData.getBytes(), Base64.DEFAULT);
httpPost.addHeader("Authentication", "Basic " + base64EncodedCredentials);
B :
httpPost.setHeader("Content-type","application/json");
httpPost.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials("[email protected]", "xxxx"), "UTF-8", false));
그리고, 무엇을 추측? 메소드 A를 사용하면 요청 헤더는 인증 만 남게됩니다. 예, "Content-type"이 사라졌습니다.
B 만 완벽하게 작동합니다.
비슷한 문제가 발생 했습니까? 제발 나를 도와주세요, 고마워.
나는 안드로이드 프로젝트를 개발 중이며 어떤 httpclient 버전인지 전혀 모른다. 여기에 뭔가가 있습니다 : http://stackoverflow.com/questions/2618573/what-version-of-apache-http-client-is-bundled-in-android-1-6/4818714#4818714 –
@adhati, check my 대답, 나는 그것을 알아 낸다. –