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-17566] Android: setting createHTTPClient properties autoRedirect ... #6532

Merged
merged 1 commit into from Jan 6, 2015

Conversation

ashcoding
Copy link
Contributor

...and autoEncodeURL

Jira: https://jira.appcelerator.org/browse/TIMOB-17566

Test app.js

var win1 = Titanium.UI.createWindow({

});

// Create a Button.
var aButton = Ti.UI.createButton({
    title : 'aButton',
});

// Listen for click events.
aButton.addEventListener('click', function() {

    var url = "http://httpbin.org/redirect/2";
    var client = Ti.Network.createHTTPClient({
        // function called when the response data is available
        onload : function(e) {
            Ti.API.info('e ' + JSON.stringify(e));
            Ti.API.info("Received HEADERS_RECEIVED: " + this.HEADERS_RECEIVED);
            Ti.API.info("Received status: " + this.status);
            alert(this.status);
            Ti.API.info("Received statusText: " + this.statusText);
            Ti.API.info("Received responseText: " + this.responseText);

            alert('success');
        },
        // function called when an error occurs, including a timeout
        onerror : function(e) {
            Ti.API.debug(e.error);
            Ti.API.info("Received HEADERS_RECEIVED: " + this.HEADERS_RECEIVED);
            Ti.API.info("Received status: " + this.status);
            alert(this.status);
            Ti.API.info("Received statusText: " + this.statusText);
            Ti.API.info("Received responseText: " + this.responseText);

            alert('error');
        },
        timeout : 5000, // in milliseconds*

        autoRedirect : false,
        autoEncodeUrl : false,

    });


    // Prepare the connection.

    client.open("GET", url);
    // Send the request.
    client.send();

});

// Add to the parent view.
win1.add(aButton);

win1.open();

@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Request accepted

hieupham007 added a commit that referenced this pull request Jan 6, 2015
[TIMOB-17566] Android: setting createHTTPClient properties autoRedirect ...
@hieupham007 hieupham007 merged commit 84ac7b6 into tidev:master Jan 6, 2015
@ashcoding ashcoding deleted the TIMOB-17566 branch May 21, 2015 07:28
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

2 participants