Repository navigation
Expand file tree
/
Copy pathHttpRequest.java
More file actions
168 lines (133 loc) · 3.48 KB
/
Copy pathHttpRequest.java
File metadata and controls
168 lines (133 loc) · 3.48 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package com.pubnub.api;
import java.util.Enumeration;
import java.util.Hashtable;
import com.pubnub.api.PubnubUtil;
class HttpRequest {
private volatile ResponseHandler responseHandler;
private Hashtable headers;
private String[] urlComponents;
private Hashtable params;
private String url;
private String body;
private String method = "GET";
private boolean dar;
private boolean subzero;
private Worker _worker;
public boolean isSubzero() {
return subzero;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public void setWorker(Worker worker) {
this._worker = worker;
}
public Worker getWorker() {
return this._worker;
}
public void setSubzero(boolean subzero) {
this.subzero = subzero;
}
public boolean isDar() {
return dar;
}
public void setDar(boolean dar) {
this.dar = dar;
}
public HttpRequest(String[] urlComponents, Hashtable params,
Hashtable headers, ResponseHandler rh) {
this.setUrlComponents(urlComponents);
this.setParams(params);
this.setHeaders(headers);
this.setResponseHandler(rh);
}
public HttpRequest(String[] urlComponents, Hashtable params,
ResponseHandler rh) {
this.setUrlComponents(urlComponents);
this.setParams(params);
this.setResponseHandler(rh);
}
public HttpRequest(String[] urlComponents, ResponseHandler rh) {
this.setUrlComponents(urlComponents);
this.setResponseHandler(rh);
}
public HttpRequest(String[] urlComponents, Hashtable params,
Hashtable headers, String body, ResponseHandler rh) {
this.setUrlComponents(urlComponents);
this.setParams(params);
this.setHeaders(headers);
this.setResponseHandler(rh);
this.setBody(body);
}
public HttpRequest(String[] urlComponents, Hashtable params,
String body, ResponseHandler rh) {
this.setUrlComponents(urlComponents);
this.setParams(params);
this.setResponseHandler(rh);
this.setBody(body);
}
public HttpRequest(String[] urlComponents, String body, ResponseHandler rh) {
this.setUrlComponents(urlComponents);
this.setResponseHandler(rh);
this.setBody(body);
}
public String[] getUrlComponents() {
return urlComponents;
}
public void setUrlComponents(String[] urlComponents) {
this.urlComponents = urlComponents;
}
public Hashtable getParams() {
return params;
}
public void setParams(Hashtable params) {
this.params = params;
}
public ResponseHandler getResponseHandler() {
return responseHandler;
}
public void setResponseHandler(ResponseHandler responseHandler) {
this.responseHandler = responseHandler;
}
public Hashtable getHeaders() {
return headers;
}
public void setHeaders(Hashtable headers) {
this.headers = headers;
}
public String getUrl() {
if (url != null) {
return url;
}
String url = PubnubUtil.joinString(urlComponents, "/");
if (this.params != null && this.params.size() > 0) {
StringBuffer sb = new StringBuffer();
sb.append(url).append("?");
Enumeration paramsKeys = this.params.keys();
boolean first = true;
while (paramsKeys.hasMoreElements()) {
if (!first) {
sb.append("&");
} else
first = false;
String key = (String) paramsKeys.nextElement();
sb.append(PubnubUtil.urlEncode((String) key))
.append("=")
.append(PubnubUtil.urlEncode((String) this.params
.get(key)));
}
url = sb.toString();
}
this.url = url;
return this.url;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}