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

Fixes for [TC-1557] and [TC-1792], changes in HTTPClient.js. #3693

Closed
wants to merge 2 commits into from

Conversation

edgithub
Copy link
Contributor

This pull request contains fixes for the following issues:

Ti.Blob does not do Base64 enc/deccoding as specified in the docs
@yaroslavp-gl
Copy link
Contributor

The Jira issue: https://jira.appcelerator.org/browse/TC-1557


//This variable shows that responseType of XMLHttpRequest is 'arraybuffer'
//This type is valid only for async mode
_isArrayBuffer: void 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no point in creating a property with a default value of undefined. It is undefined by default and this line just wastes bytes

@nebrius
Copy link
Contributor

nebrius commented Jan 14, 2013

This PR adds support for new features. Anytime there is support for a new feature, the Docs must also be updated. If you don't update the docs, this PR will be rejected.

f = Filesystem.getFile(f);
f.writable && f.write(xhr.responseText);
//create file by name
this.file && (file = Filesystem.getFile(Filesystem.applicationDataDirectory, this.file));
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't work. By prepending the applicationDataDirectory, you're disallowing someone to save the response to the tempDirectory.

Furthermore, you're forcing someone to enter a non-fully qualified path for the "file" property which conflicts with the default behavior for non-fully qualified paths. Non-fully qualified paths default to the Resources directory, which isn't writable anyways.

And if someone passes in a fully qualified path that is in the applicationDataDirectory, it will be set twice and error as an invalid path.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I wouldn't define this so far above where it's next used.

@yaroslavp-gl
Copy link
Contributor

Latest change (committed 16.01.2013) was tested on iOS 5.0.1, iOS 4.1, Android 2.3, Android 4.0.


//prepare Base64-encoded string required by Blob
var i = c.responseText.length,
binaryString = new Array(i);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just do:

binaryString = [];

It saves bytes, and you won't incur much of a performance penalty

Copy link
Contributor

Choose a reason for hiding this comment

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

On second though, given the length of the buffer, the performance hit will add up over time.

Copy link
Contributor

Choose a reason for hiding this comment

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

edgithub, please disregard Bryan's comment. Using new Array(i) is the preferred way.

@nebrius
Copy link
Contributor

nebrius commented Jan 17, 2013

Before we proceed further, I need you to attach a test case to the JIRA ticket highlighting the problem in the original implementation

@yaroslavp-gl
Copy link
Contributor

Please refer to the ticket https://jira.appcelerator.org/browse/TIMOB-12394 for the test case sample.

@nebrius
Copy link
Contributor

nebrius commented Jan 24, 2013

I dug into this issue a little more, and, in short, the wrong thing was fixed. HTTPClient works just fine, and Blob mostly works just fine (there are some issues with toString, but that is unrelated to this issue). The bug is in ImageView. We don't base64 encode blobs anymore, so imageview needs to be updated to base64 encode the data from blobs.

Request rejected

@nebrius nebrius closed this Jan 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants