List of usage examples for javax.net.ssl HttpsURLConnection getRequestProperties
public Map<String, List<String>> getRequestProperties()
From source file:com.dao.ShopThread.java
private void pay(String payurl) { LogUtil.debugPrintf("----------->"); try {/*from www.j a v a2 s. c om*/ String postParams = getPayDynamicParams(payurl); HttpsURLConnection loginConn = getHttpSConn(payurl, "POST", Integer.toString(postParams.length())); if (null != this.cookies) { loginConn.addRequestProperty("Cookie", GenericUtil.cookieFormat(this.cookies)); } LogUtil.debugPrintf("HEADER===" + loginConn.getRequestProperties()); DataOutputStream wr = new DataOutputStream(loginConn.getOutputStream()); wr.writeBytes(postParams); wr.flush(); wr.close(); int responseCode = loginConn.getResponseCode(); LogUtil.debugPrintf("\nSending 'POST' request to URL : " + payurl); LogUtil.debugPrintf("Post parameters :" + postParams); LogUtil.debugPrintf("Response Code : " + responseCode); Map<String, List<String>> header = loginConn.getHeaderFields(); LogUtil.debugPrintf("conn.getHeaderFields():" + header); BufferedReader in = new BufferedReader(new InputStreamReader(loginConn.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(2000); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); String payresponse = response.toString(); LogUtil.debugPrintf("payresponse:" + payresponse); List<String> cookie = header.get("Set-Cookie"); String loginInfo; if (responseCode != 302) { LogUtil.debugPrintf("----------->"); loginInfo = ""; } else { LogUtil.debugPrintf("?----------->"); if (null != cookie && cookie.size() > 0) { LogUtil.debugPrintf("cookie====" + cookie); setCookies(cookie); } loginInfo = "?"; } LogUtil.webPrintf(loginInfo); } catch (Exception e) { e.printStackTrace(); } }