@@ -69,46 +69,62 @@ public void setExtraHeader(String name, String value) {
6969 }
7070
7171 public ClientResponse get (String path ) throws LaraApiConnectionException {
72- return get (path , null );
72+ return get (path , null , null );
7373 }
7474
7575 public ClientResponse get (String path , Map <String , Object > params ) throws LaraApiConnectionException {
76- return request ("GET" , path , params , null );
76+ return get (path , params , null );
77+ }
78+
79+ public ClientResponse get (String path , Map <String , Object > params , Map <String , String > headers ) throws LaraApiConnectionException {
80+ return request ("GET" , path , params , null , headers );
7781 }
7882
7983 public ClientResponse delete (String path ) throws LaraException {
80- return delete (path , null );
84+ return delete (path , null , null );
85+ }
86+
87+ public ClientResponse delete (String path , Map <String , Object > params ) throws LaraException {
88+ return delete (path , params , null );
8189 }
8290
83- public ClientResponse delete (String path , Map <String , Object > params ) throws LaraApiConnectionException {
84- return request ("DELETE" , path , params , null );
91+ public ClientResponse delete (String path , Map <String , Object > params , Map < String , String > headers ) throws LaraApiConnectionException {
92+ return request ("DELETE" , path , params , null , headers );
8593 }
8694
8795 public ClientResponse post (String path ) throws LaraException {
88- return post (path , null , null );
96+ return post (path , null , null , null );
8997 }
9098
91- public ClientResponse post (String path , Map <String , Object > params ) throws LaraApiConnectionException {
92- return post (path , params , null );
99+ public ClientResponse post (String path , Map <String , Object > params ) throws LaraException {
100+ return post (path , params , null , null );
93101 }
94102
95103 public ClientResponse post (String path , Map <String , Object > params , Map <String , File > files ) throws LaraApiConnectionException {
96- return request ("POST" , path , params , files );
104+ return post (path , params , files , null );
105+ }
106+
107+ public ClientResponse post (String path , Map <String , Object > params , Map <String , File > files , Map <String , String > headers ) throws LaraApiConnectionException {
108+ return request ("POST" , path , params , files , headers );
97109 }
98110
99111 public ClientResponse put (String path ) throws LaraException {
100- return put (path , null , null );
112+ return put (path , null , null , null );
101113 }
102114
103115 public ClientResponse put (String path , Map <String , Object > params ) throws LaraApiConnectionException {
104- return put (path , params , null );
116+ return put (path , params , null , null );
105117 }
106118
107119 public ClientResponse put (String path , Map <String , Object > params , Map <String , File > files ) throws LaraApiConnectionException {
108- return request ( "PUT" , path , params , files );
120+ return put ( path , params , files , null );
109121 }
110122
111- private ClientResponse request (String method , String path , Map <String , Object > params , Map <String , File > files ) throws LaraApiConnectionException {
123+ public ClientResponse put (String path , Map <String , Object > params , Map <String , File > files , Map <String , String > headers ) throws LaraApiConnectionException {
124+ return request ("PUT" , path , params , files , headers );
125+ }
126+
127+ private ClientResponse request (String method , String path , Map <String , Object > params , Map <String , File > files , Map <String , String > headers ) throws LaraApiConnectionException {
112128 path = normalizePath (path );
113129 params = prune (params );
114130 files = prune (files );
@@ -145,6 +161,12 @@ private ClientResponse request(String method, String path, Map<String, Object> p
145161 for (Map .Entry <String , String > header : extraHeaders .entrySet ())
146162 connection .setRequestProperty (header .getKey (), header .getValue ());
147163
164+ // headers
165+ if (headers != null ) {
166+ for (Map .Entry <String , String > header : headers .entrySet ())
167+ connection .setRequestProperty (header .getKey (), header .getValue ());
168+ }
169+
148170 // http method
149171 connection .setRequestMethod ("POST" );
150172
0 commit comments