File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ public class PostRequest
26
26
String url ;
27
27
ArrayList <BasicNameValuePair > nameValuePairs ;
28
28
HashMap <String ,File > nameFilePairs ;
29
+ ArrayList <BasicNameValuePair > headerPairs ;
30
+
29
31
30
32
String content ;
31
33
String encoding ;
@@ -49,6 +51,12 @@ public void addUser(String user, String pwd)
49
51
{
50
52
creds = new UsernamePasswordCredentials (user , pwd );
51
53
}
54
+
55
+ public void addHeader (String key ,String value ) {
56
+ BasicNameValuePair nvp = new BasicNameValuePair (key ,value );
57
+ headerPairs .add (nvp );
58
+
59
+ }
52
60
53
61
public void addData (String key , String value )
54
62
{
@@ -92,6 +100,12 @@ public void send()
92
100
httpPost .setEntity (mentity );
93
101
}
94
102
103
+ Iterator <BasicNameValuePair > headerIterator = headerPairs .iterator ();
104
+ while (headerIterator .hasNext ()) {
105
+ BasicNameValuePair headerPair = headerIterator .next ();
106
+ httpPost .addHeader (headerPair .getName (),headerPair .getValue ());
107
+ }
108
+
95
109
response = httpClient .execute ( httpPost );
96
110
HttpEntity entity = response .getEntity ();
97
111
this .content = EntityUtils .toString (response .getEntity ());
You can’t perform that action at this time.
0 commit comments