Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24809] Android: HTTPClient - "onload" not dispatched. #9139

Merged
merged 8 commits into from
Jun 14, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ private Object titaniumFileAsPutData(Object value)

public void send(Object userData) throws UnsupportedEncodingException
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to clear the values only after they have been used:

L1145

if (nvPairs.size() > 0) {
	try {
		form = new UrlEncodedFormEntity(nvPairs, "UTF-8");
	} catch (UnsupportedEncodingException e) {
		Log.e(TAG, "Unsupported encoding: ", e);
	}
	nvPairs.clear();
}

L1198

for(String name : parts.keySet()) {
	Log.d(TAG, "adding part " + name + ", part type: " + parts.get(name).getMimeType() + ", len: "
			+ parts.get(name).getContentLength(), Log.DEBUG_MODE);
	addFilePart(name, parts.get(name));
}
parts.clear();

aborted = false;

// TODO consider using task manager
Expand Down Expand Up @@ -1143,6 +1144,8 @@ public void run()
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Unsupported encoding: ", e);
}
//clear nvPairs after form entity is created
nvPairs.clear();
}

// calculate content length
Expand Down Expand Up @@ -1196,7 +1199,8 @@ public void progress(int progress) {
+ parts.get(name).getContentLength(), Log.DEBUG_MODE);
addFilePart(name, parts.get(name));
}

//clear parts after they have been used
parts.clear();
if (form != null) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream((int) form.getContentLength());
Expand Down