아래와 같이 http post body를 구성하여 통신을 하고 있습니다.
HttpClient httpClient = new DefaultHttpClient();
HttpParams httpparams = httpClient.getParams();
HttpConnectionParams.setConnectionTimeout(httpparams, 5000);
HttpConnectionParams.setSoTimeout(httpparams, 5000);
HttpPost request = new HttpPost(url);
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("timestamp", mDevice.getwifiTime()));
postParameters.add(new BasicNameValuePair("x-uploadport", mDevice.Port));
postParameters.add(new BasicNameValuePair("x-useSSL", mDevice.SSL));
postParameters.add(new BasicNameValuePair("x-uploadpath", URLEncoder.encode(m_DeviceRegisterBlueLineModel.sUri, "UTF-8")));
(new BasicNameValuePair("x-uploadhost", URLEncoder.encode(m_DeviceRegisterBlueLineModel.sHost, "UTF-8")));
postParameters.add(new BasicNameValuePair("x-authcode", mDevice.sAuthToken.replace("=", "%3D")));
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(
postParameters, HTTP.UTF_8);
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
request.setEntity(formEntity);
위의 구문에서 body가 어떻게 구성되는 확인 하려면 postParameters.toString()으로 확인 가능한가요..?
body 구성이 아래와 같이 되어야 하는데요, 지금 쓰고 있는 List<NameValuePair> 에 add하는 방식으로 아래와 같은 형태로 body 구성이 가능한지도 궁금합니다.
timestamp=1409005992&x-uploadport=8080&x-useSSL=no&x-uploadpath=%2Fdeviceio%2Fblpcm&x-uploadhost=esp%2Epeopleco%2Ecom&x-authcode=FHocyu9Z2GaWiIG%2B%2B461Invm1OffEgiWl0O0vx%2FQk1g%3Dg%3D
고수님들 답변 부탁드립니다.