Skip to content

Commit 6bcb0a9

Browse files
committed
Updated documentation, javadocs and formatted code
1 parent a4e4da7 commit 6bcb0a9

File tree

10 files changed

+67
-43
lines changed

10 files changed

+67
-43
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
- Added support for HTTP PATCH requests
1010
- Fixed Assert exception when mkdirs in FileAsyncHttpResponseHandler tries to create dirs that already exists
1111
- Provided option to easily override ClientConnectionManager provision in AsyncHttpClient
12+
- Changed onProgress from (int,int) to (long,long) for dealing with large transfers
13+
- Renamed typo of `preemtive` to `preemptive` (preemptive basic auth)
14+
- Added option to put File array in RequestParams
15+
- RequestParams now support forcing Content-Type into `multipart/form-data` even if there are no files/streams to be multiparted
16+
- Gradle added support for installing to local maven repository, through `gradle installArchives` task
17+
- Added support for Json RFC5179 in JsonHttpResponseHandler
1218

1319
## 1.4.6 (released 7. 9. 2014)
1420

library/src/main/java/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,8 @@ public void setBasicAuth(String username, String password) {
632632
* Sets basic authentication for the request. Uses AuthScope.ANY. This is the same as
633633
* setBasicAuth('username','password',AuthScope.ANY)
634634
*
635-
* @param username Basic Auth username
636-
* @param password Basic Auth password
635+
* @param username Basic Auth username
636+
* @param password Basic Auth password
637637
* @param preemptive sets authorization in preemptive manner
638638
*/
639639
public void setBasicAuth(String username, String password, boolean preemptive) {
@@ -656,9 +656,9 @@ public void setBasicAuth(String username, String password, AuthScope scope) {
656656
* Sets basic authentication for the request. You should pass in your AuthScope for security. It
657657
* should be like this setBasicAuth("username","password", new AuthScope("host",port,AuthScope.ANY_REALM))
658658
*
659-
* @param username Basic Auth username
660-
* @param password Basic Auth password
661-
* @param scope an AuthScope object
659+
* @param username Basic Auth username
660+
* @param password Basic Auth password
661+
* @param scope an AuthScope object
662662
* @param preemptive sets authorization in preemptive manner
663663
*/
664664
public void setBasicAuth(String username, String password, AuthScope scope, boolean preemptive) {
@@ -1095,7 +1095,8 @@ public RequestHandle put(Context context, String url, Header[] headers, HttpEnti
10951095
}
10961096

10971097
/**
1098-
* Perform a HTTP PATCH request, without any parameters.
1098+
* Perform a HTTP
1099+
* request, without any parameters.
10991100
*
11001101
* @param url the URL to send the request to.
11011102
* @param responseHandler the response handler instance that should handle the response.
@@ -1136,6 +1137,11 @@ public RequestHandle patch(Context context, String url, RequestParams params, Re
11361137
* @param context the Android Context which initiated the request.
11371138
* @param url the URL to send the request to.
11381139
* @param responseHandler the response handler instance that should handle the response.
1140+
* @param entity a raw {@link HttpEntity} to send with the request, for example, use
1141+
* this to send string/json/xml payloads to a server by passing a {@link
1142+
* org.apache.http.entity.StringEntity}
1143+
* @param contentType the content type of the payload you are sending, for example
1144+
* "application/json" if sending a json payload.
11391145
* @return RequestHandle of future request process
11401146
*/
11411147
public RequestHandle patch(Context context, String url, HttpEntity entity, String contentType, ResponseHandlerInterface responseHandler) {
@@ -1397,7 +1403,7 @@ public static String getUrlWithQueryString(boolean shouldEncodeUrl, String url,
13971403
*
13981404
* @param inputStream InputStream to be checked
13991405
* @return true or false if the stream contains GZIP compressed data
1400-
* @throws java.io.IOException
1406+
* @throws java.io.IOException if read from inputStream fails
14011407
*/
14021408
public static boolean isInputStreamGZIPCompressed(final PushbackInputStream inputStream) throws IOException {
14031409
if (inputStream == null)

library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* {@link #onSuccess(int, org.apache.http.Header[], byte[])} method is designed to be anonymously
4040
* overridden with your own response handling code. <p>&nbsp;</p> Additionally, you can override the
4141
* {@link #onFailure(int, org.apache.http.Header[], byte[], Throwable)}, {@link #onStart()}, {@link
42-
* #onFinish()}, {@link #onRetry(int)} and {@link #onProgress(int, int)} methods as required.
42+
* #onFinish()}, {@link #onRetry(int)} and {@link #onProgress(long, long)} methods as required.
4343
* <p>&nbsp;</p> For example: <p>&nbsp;</p>
4444
* <pre>
4545
* AsyncHttpClient client = new AsyncHttpClient();

library/src/main/java/com/loopj/android/http/HttpDelete.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ public HttpDelete() {
3535
super();
3636
}
3737

38+
/**
39+
* @param uri target url as URI
40+
*/
3841
public HttpDelete(final URI uri) {
3942
super();
4043
setURI(uri);
4144
}
4245

4346
/**
47+
* @param uri target url as String
4448
* @throws IllegalArgumentException if the uri is invalid.
45-
*/
49+
*/
4650
public HttpDelete(final String uri) {
47-
super();
48-
setURI(URI.create(uri));
51+
super();
52+
setURI(URI.create(uri));
4953
}
5054

5155
@Override

library/src/main/java/com/loopj/android/http/HttpGet.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ public HttpGet() {
3636
super();
3737
}
3838

39+
/**
40+
* @param uri target url as URI
41+
*/
3942
public HttpGet(final URI uri) {
4043
super();
4144
setURI(uri);
4245
}
4346

4447
/**
48+
* @param uri target url as String
4549
* @throws IllegalArgumentException if the uri is invalid.
46-
*/
50+
*/
4751
public HttpGet(final String uri) {
48-
super();
49-
setURI(URI.create(uri));
52+
super();
53+
setURI(URI.create(uri));
5054
}
5155

5256
@Override

library/src/main/java/com/loopj/android/http/HttpPatch.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,38 @@
1818

1919
package com.loopj.android.http;
2020

21-
import java.net.URI;
2221
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
2322

23+
import java.net.URI;
24+
2425
/**
2526
* The current Android (API level 21) bundled version of the Apache Http Client does not implement
26-
* the HTTP PATCH method. Until the Android version is updated this can serve in it's stead.
27+
* the HTTP PATCH method. Until the Android version is updated this can serve in it's stead.
2728
* This implementation can and should go away when the official solution arrives.
2829
*/
2930
public final class HttpPatch extends HttpEntityEnclosingRequestBase {
30-
31+
3132
public final static String METHOD_NAME = "PATCH";
3233

3334
public HttpPatch() {
3435
super();
3536
}
3637

38+
/**
39+
* @param uri target url as URI
40+
*/
3741
public HttpPatch(final URI uri) {
3842
super();
3943
setURI(uri);
4044
}
4145

4246
/**
47+
* @param uri target url as String
4348
* @throws IllegalArgumentException if the uri is invalid.
44-
*/
49+
*/
4550
public HttpPatch(final String uri) {
46-
super();
47-
setURI(URI.create(uri));
51+
super();
52+
setURI(URI.create(uri));
4853
}
4954

5055
@Override

library/src/main/java/com/loopj/android/http/JsonValueInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* not rely on {@link org.json.JSONArray} or {@link org.json.JSONObject} to
2525
* exchange data.
2626
*
27-
* @author Noor Dawod <[email protected]>
27+
* @author Noor Dawod {@literal <[email protected]>}
2828
*/
2929
public interface JsonValueInterface {
3030

library/src/main/java/com/loopj/android/http/RequestParams.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public class RequestParams implements Serializable {
109109
protected final ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap<String, String>();
110110
protected final ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap<String, StreamWrapper>();
111111
protected final ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap<String, FileWrapper>();
112-
protected final ConcurrentHashMap<String, List<FileWrapper> >fileArrayParams = new ConcurrentHashMap<String, List<FileWrapper>>();
112+
protected final ConcurrentHashMap<String, List<FileWrapper>> fileArrayParams = new ConcurrentHashMap<String, List<FileWrapper>>();
113113
protected final ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap<String, Object>();
114114
protected String contentEncoding = HTTP.UTF_8;
115115

@@ -130,7 +130,7 @@ public void setContentEncoding(final String encoding) {
130130
/**
131131
* If set to true will force Content-Type header to `multipart/form-data`
132132
* even if there are not Files or Streams to be send
133-
*
133+
* <p>&nbsp;</p>
134134
* Default value is false
135135
*
136136
* @param force boolean, should declare content-type multipart/form-data even without files or streams present
@@ -207,35 +207,34 @@ public void put(String key, String value) {
207207
/**
208208
* Adds files array to the request.
209209
*
210-
* @param key the key name for the new param.
210+
* @param key the key name for the new param.
211211
* @param files the files array to add.
212-
* @throws FileNotFoundException
212+
* @throws FileNotFoundException if one of passed files is not found at time of assembling the requestparams into request
213213
*/
214214
public void put(String key, File files[]) throws FileNotFoundException {
215215
put(key, files, null, null);
216216
}
217217

218218
/**
219-
*
220219
* Adds files array to the request with both custom provided file content-type and files name
221220
*
222221
* @param key the key name for the new param.
223-
* @param files the files array to add.
222+
* @param files the files array to add.
224223
* @param contentType the content type of the file, eg. application/json
225224
* @param customFileName file name to use instead of real file name
226225
* @throws FileNotFoundException throws if wrong File argument was passed
227226
*/
228227
public void put(String key, File files[], String contentType, String customFileName) throws FileNotFoundException {
229228

230-
if(key != null){
229+
if (key != null) {
231230
List<FileWrapper> fileWrappers = new ArrayList<FileWrapper>();
232-
for (int i=0;i<files.length;i++){
233-
if(files[i] == null || !files[i].exists()){
231+
for (int i = 0; i < files.length; i++) {
232+
if (files[i] == null || !files[i].exists()) {
234233
throw new FileNotFoundException();
235234
}
236235
fileWrappers.add(new FileWrapper(files[i], contentType, customFileName));
237236
}
238-
fileArrayParams.put(key,fileWrappers);
237+
fileArrayParams.put(key, fileWrappers);
239238
}
240239
}
241240

@@ -489,7 +488,7 @@ public void setUseJsonStreamer(boolean flag) {
489488
* Sets an additional field when upload a JSON object through the streamer
490489
* to hold the time, in milliseconds, it took to upload the payload. By
491490
* default, this field is set to "_elapsed".
492-
*
491+
* <p>&nbsp;</p>
493492
* To disable this feature, call this method with null as the field value.
494493
*
495494
* @param value field name to add elapsed time, or null to disable
@@ -606,7 +605,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
606605
// Add file collection
607606
for (ConcurrentHashMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
608607
List<FileWrapper> fileWrapper = entry.getValue();
609-
for (FileWrapper fw:fileWrapper){
608+
for (FileWrapper fw : fileWrapper) {
610609
entity.addPart(entry.getKey(), fw.file, fw.contentType, fw.customFileName);
611610
}
612611
}

library/src/main/java/com/loopj/android/http/ResponseHandlerInterface.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,28 +91,28 @@ public interface ResponseHandlerInterface {
9191
*
9292
* @return uri of origin request
9393
*/
94-
public URI getRequestURI();
94+
URI getRequestURI();
9595

9696
/**
9797
* Returns Header[] which were used to request
9898
*
9999
* @return headers from origin request
100100
*/
101-
public Header[] getRequestHeaders();
101+
Header[] getRequestHeaders();
102102

103103
/**
104104
* Helper for handlers to receive Request URI info
105105
*
106106
* @param requestURI claimed request URI
107107
*/
108-
public void setRequestURI(URI requestURI);
108+
void setRequestURI(URI requestURI);
109109

110110
/**
111111
* Helper for handlers to receive Request Header[] info
112112
*
113113
* @param requestHeaders Headers, claimed to be from original request
114114
*/
115-
public void setRequestHeaders(Header[] requestHeaders);
115+
void setRequestHeaders(Header[] requestHeaders);
116116

117117
/**
118118
* Can set, whether the handler should be asynchronous or synchronous
@@ -148,7 +148,7 @@ public interface ResponseHandlerInterface {
148148
* This method is called once by the system when the response is about to be
149149
* processed by the system. The library makes sure that a single response
150150
* is pre-processed only once.
151-
* <p/>
151+
* <p>&nbsp;</p>
152152
* Please note: pre-processing does NOT run on the main thread, and thus
153153
* any UI activities that you must perform should be properly dispatched to
154154
* the app's UI thread.
@@ -162,7 +162,7 @@ public interface ResponseHandlerInterface {
162162
* This method is called once by the system when the request has been fully
163163
* sent, handled and finished. The library makes sure that a single response
164164
* is post-processed only once.
165-
* <p/>
165+
* <p>&nbsp;</p>
166166
* Please note: post-processing does NOT run on the main thread, and thus
167167
* any UI activities that you must perform should be properly dispatched to
168168
* the app's UI thread.

library/src/main/java/com/loopj/android/http/SaxAsyncHttpResponseHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
/**
3939
* Provides interface to deserialize SAX responses, using AsyncHttpResponseHandler. Can be used like
4040
* this
41-
*
41+
* <p>&nbsp;</p>
4242
* <pre>
4343
* AsyncHttpClient ahc = new AsyncHttpClient();
4444
* FontHandler handlerInstance = ... ; // init handler instance
45-
* ahc.post("https://server.tld/api/call", new SaxAsyncHttpResponseHandler<FontHandler>(handlerInstance){
45+
* ahc.post("https://server.tld/api/call", new SaxAsyncHttpResponseHandler{@literal <}FontHandler{@literal >}(handlerInstance){
4646
* &#064;Override
4747
* public void onSuccess(int statusCode, Header[] headers, FontHandler t) {
4848
* // Request got HTTP success statusCode
@@ -52,7 +52,7 @@
5252
* // Request got HTTP fail statusCode
5353
* }
5454
* });
55-
* <pre/>
55+
* </pre>
5656
*
5757
* @param <T> Handler extending {@link org.xml.sax.helpers.DefaultHandler}
5858
* @see org.xml.sax.helpers.DefaultHandler
@@ -85,7 +85,7 @@ public SaxAsyncHttpResponseHandler(T t) {
8585
*
8686
* @param entity returned HttpEntity
8787
* @return deconstructed response
88-
* @throws java.io.IOException
88+
* @throws java.io.IOException if there is problem assembling SAX response from stream
8989
* @see org.apache.http.HttpEntity
9090
*/
9191
@Override

0 commit comments

Comments
 (0)