cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package cn.ksource.web.alipay.util.httpClient;
 
import java.io.UnsupportedEncodingException;
 
import org.apache.commons.httpclient.Header;
 
import cn.ksource.web.alipay.config.AlipayConfig;
 
 
/* *
 *类名:HttpResponse
 *功能:Http返回对象的封装
 *详细:封装Http返回信息
 *版本:3.3
 *日期:2011-08-17
 *说明:
 *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
 */
 
public class HttpResponse {
 
    /**
     * 返回中的Header信息
     */
    private Header[] responseHeaders;
 
    /**
     * String类型的result
     */
    private String   stringResult;
 
    /**
     * btye类型的result
     */
    private byte[]   byteResult;
 
    public Header[] getResponseHeaders() {
        return responseHeaders;
    }
 
    public void setResponseHeaders(Header[] responseHeaders) {
        this.responseHeaders = responseHeaders;
    }
 
    public byte[] getByteResult() {
        if (byteResult != null) {
            return byteResult;
        }
        if (stringResult != null) {
            return stringResult.getBytes();
        }
        return null;
    }
 
    public void setByteResult(byte[] byteResult) {
        this.byteResult = byteResult;
    }
 
    public String getStringResult() throws UnsupportedEncodingException {
        if (stringResult != null) {
            return stringResult;
        }
        if (byteResult != null) {
            return new String(byteResult, AlipayConfig.input_charset);
        }
        return null;
    }
 
    public void setStringResult(String stringResult) {
        this.stringResult = stringResult;
    }
 
}