Created
August 13, 2014 04:48
-
-
Save arkty/227b92d1902cfc334d94 to your computer and use it in GitHub Desktop.
android-async-http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void multipartBoundaryMissed() throws IOException { | |
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "tempfile.dmp"); | |
file.createNewFile(); | |
AsyncHttpClient client = new AsyncHttpClient(); | |
RequestParams params = new RequestParams(); | |
params.put("access_token", "AFVVD"); | |
params.put("file", file); | |
Header[] headers = new Header[0]; | |
params.put("comment", "line missed"); | |
// Boundary line missed | |
client.post((Context)this, "http://example.com", headers, params, "multipart/form-data", new AsyncHttpResponseHandler() { | |
@Override | |
public void onSuccess(int i, Header[] headers, byte[] bytes) { | |
} | |
@Override | |
public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | |
} | |
}); | |
params.put("comment", "line ok"); | |
// Boundary line ok | |
client.post((Context)this, "http://example.com", headers, params, null, new AsyncHttpResponseHandler() { | |
@Override | |
public void onSuccess(int i, Header[] headers, byte[] bytes) { | |
} | |
@Override | |
public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) { | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST / HTTP/1.1 | |
Content-Type: multipart/form-data | |
Content-Length: 494 | |
Host: example.com | |
Connection: Keep-Alive | |
Accept-Encoding: gzip | |
--TGG6SycfyavFIskvoUnI6_x1EUtrmZ | |
Content-Disposition: form-data; name="comment" | |
Content-Type: text/plain; charset=UTF-8 | |
line missed | |
--TGG6SycfyavFIskvoUnI6_x1EUtrmZ | |
Content-Disposition: form-data; name="access_token" | |
Content-Type: text/plain; charset=UTF-8 | |
AFVVD | |
--TGG6SycfyavFIskvoUnI6_x1EUtrmZ | |
Content-Disposition: form-data; name="file"; filename="tempfile.dmp" | |
Content-Type: application/octet-stream | |
Content-Transfer-Encoding: binary | |
--TGG6SycfyavFIskvoUnI6_x1EUtrmZ-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST / HTTP/1.1 | |
Content-Length: 490 | |
Content-Type: multipart/form-data; boundary=xJDvHsaUKOwYWEwY2q2xJu0E4JQFhJ | |
Host: example.com | |
Connection: Keep-Alive | |
Accept-Encoding: gzip | |
--xJDvHsaUKOwYWEwY2q2xJu0E4JQFhJ | |
Content-Disposition: form-data; name="comment" | |
Content-Type: text/plain; charset=UTF-8 | |
line ok | |
--xJDvHsaUKOwYWEwY2q2xJu0E4JQFhJ | |
Content-Disposition: form-data; name="access_token" | |
Content-Type: text/plain; charset=UTF-8 | |
AFVVD | |
--xJDvHsaUKOwYWEwY2q2xJu0E4JQFhJ | |
Content-Disposition: form-data; name="file"; filename="tempfile.dmp" | |
Content-Type: application/octet-stream | |
Content-Transfer-Encoding: binary | |
--xJDvHsaUKOwYWEwY2q2xJu0E4JQFhJ-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment