Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

httpclient broken for 1.5.0 > githash=1dd0106

CORRECTION githash=3ee6a97

Hi
What's going on with the httpClient?

The version with githash=3ee6a97 is the last working fine, all that are above this breaks httpclient trying to parse a html code as xml.

Of course this breaks the yql too.

Any ideas?

— asked December 1st 2010 by Dan Tamas
  • httpclient
  • ios
  • parsexml
2 Comments
  • Okay, I've asked about, and the issue was that XHR was memory leaking, and as a stopgap, the valid information is shunted into a different proxy. This will be fixed in 1.5.1, but in the meantime (And as good practice anyways), use 'this' instead of referring to the xhr by name. That is:

    xhr.onload = function() {
       var json = eval( '(' + this.responseText + ')' );
    };
    
    — commented December 13th 2010 by Blain Hamon
  • Blain, have you seen my last comments on LH ?

    https://appcelerator.lighthouseapp.com/projects/32238/tickets/2480-ios-httpclient-assumes-xml-with-reponsetext-emitting-parse-error#ticket-2480-17

    It seems the httpclient works ok( I didn't made a deeper test though ), except the location stuff.

    — commented December 13th 2010 by Dan Tamas

8 Answers

  • Hey tamas, you should provide some code of a working example on a previous version to understand what you want to do. I actually did some html parsing last night and might be able to help

    — answered December 1st 2010 by Pedro Enrique
    permalink
    0 Comments
  • Nothing special, just plain httpclient.
    I keep getting this error

    [ERROR] Error Domain=com.google.GDataXML Code=-1 
    "The operation couldn’t be completed. 
    (com.google.GDataXML error -1.)". 
    in -[TiDOMDocumentProxy parseString:] (TiDOMDocumentProxy.m:50)
    

    Then a lot of xmlparser complains.

    What build do you use?

    — answered December 1st 2010 by Dan Tamas
    permalink
    0 Comments
  • This is what I did. Since you are trying to parse as an XML, single tags like <img /> will give errors. What I did was look at the code and find which tags I didn't need and which tgs where "single" tags. Then grab the text from the HTML and do a "find and replace" to remove all the possible XML errors leaving only the stuff I needed and making sure that every opening tag had a closing tag, for example, <p></p> or <a></a>. Make sense?
    Removing the image tags:

    var findImg = new RegExp("<img([^<>+]*)[^\/]>", "g");
    theStuffThatIWant = theStuffThatIWant.replace(findImg, "");
    
    — answered December 1st 2010 by Pedro Enrique
    permalink
    0 Comments
  • I'm not trying to parse anything.

    I just go to an url that has a redirect.
    I need to get the redirect location. The old version plays nice and populate the location property correctly. The new versions are simply crashing with the error I wrote previously.

    — answered December 1st 2010 by Dan Tamas
    permalink
    0 Comments
  • Some update:

    On of the last commits fixes somehow the responseXML issue, except the location problem I'm facing.
    digging into the source I found a release_to_nil that when commented it returns the location correctly.
    Here is more info

    http://bit.ly/gSa086

    — answered December 9th 2010 by Dan Tamas
    permalink
    0 Comments
  • I got same error with 1.5.0 4d92d40
    Here is my code.

    var url = 'http://maps.google.com/maps/api/geocode/json?address=kansas&sensor=true';
    var xhr = Titanium.Network.createHTTPClient();
    
    xhr.open( 'GET', url );
    xhr.onload = function() {
       var json = eval( '(' + xhr.responseText + ')' );
    };
    xhr.send();
    

    This code try to access google maps api and get Kansas gps position.
    It works with 1.4.2 and 1.2.0 but it doesnot works with 1.5.0.

    — answered December 13th 2010 by Furukawa Daisuke
    permalink
    0 Comments
  • Try the latest build, and if yo need location try the fix I posted on LH http://bit.ly/gSa086

    — answered December 13th 2010 by Dan Tamas
    permalink
    0 Comments
  • I find this is still broken with the GA release of 1.5

    — answered December 14th 2010 by Joshua Ceaser
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.