Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25241

Android: Ti.Network.createHTTPClient log 404 : Not Found error in application log

    Details

    • Story Points:
      2
    • Sprint:
      2017 Sprint 18 SDK, 2017 Sprint 19 SDK, 2017 Sprint 20 SDK, 2017 Sprint 21 SDK, 2017 Sprint 22 SDK, 2017 Sprint 23 SDK

      Description

      Reproduce Step
      1. create an app
      2. add these to index.js/app.js

      function getReadyStateNameFrom(httpClient) {
      	switch (httpClient.readyState) {
      		case httpClient.UNSENT: return "UNSENT";
      		case httpClient.OPENED: return "OPENED";
      		case httpClient.HEADERS_RECEIVED: return "HEADERS_RECEIVED";
      		case httpClient.LOADING: return "LOADING";
      		case httpClient.DONE: return "DONE";
      	}
      	return "Unknown";
      }
      var request = Ti.Network.createHTTPClient({
      	onload : function() {
      		console.log('onload: ');
      		console.log('readyState: ' + getReadyStateNameFrom(request));
      	},
      	onerror : function(e) {
      		console.log('onerror: ', e);
      		console.log('readyState: ' + getReadyStateNameFrom(request));
      	}
      });
      var url = "http://www.appcelerator.com/test.js";
      request.open("GET", url);
      request.send();
      

      3. run the app

      Actual Output
      iOS
      HTTP error responses is returned to the onerror handler

      [INFO]  onerror:  {
      [INFO]      code = 404;
      [INFO]      error = "HTTP error";
      [INFO]      source = "[object TiNetworkHTTPClient]";
      [INFO]      success = 0;
      [INFO]      type = error;
      [INFO]  }
      [INFO]  readyState: DONE
      

      Android
      Following output is logged as an eror in the application log.

      [ERROR] TiHTTPClient: (TiHttpClient-1) [22,967] HTTP Error (java.io.IOException): 404 : Not Found
      [ERROR] TiHTTPClient: java.io.IOException: 404 : Not Found
      [ERROR] TiHTTPClient: 	at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1283)
      [ERROR] TiHTTPClient: 	at java.lang.Thread.run(Thread.java:761)
      [INFO]  onerror:  {"source":{"username":null,"status":404,"location":"http://www.appcelerator.com/test.js","readyState":3,"domain":null,"statusText":"Not Found","validatesSecureCertificate":false,"password":null,"connected":false,"autoEncodeUrl":true,"connectionType":"GET","autoRedirect":true,"responseData":{"height":0,"type":2,"mimeType":"text/html","text":"<!DOCTYPE html>\n<html lang=\"en-US\"\n\titemscope \n\titemtype=\"http://schema.org/WebSite\" \n\tprefix=\"og: http://ogp.me/ns#\" >\n<head>\n\t<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\">\n\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n\t<meta charset=\"UTF-8\">\n\t<meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0\">\n\t<title>Nothing found for  Test Js</title>\n\t<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"//fonts.googleapis.com/css?family=Open+Sans:300,400,700,800,400italic,700italic|PT+Sans:400,700|Source+Sans+Pro:200,300,400,600,700\">\n  <link href=\"//vjs.zencdn.net/4.12/video-js.css\" rel=\"stylesheet\">\n  <script src=\"//vjs.zencdn.net/4.12/video.js\"></script>\n\t    <!-- LEGACY STYLES -->\n    <link rel=\"stylesheet\" id=\"ss-main\" type=\"text/css\" media=\"all\" href=\"https://www.appcelerator.com/wp-content/themes/appc-rwd/style.css?ver=00717\">\n    <link rel=\"stylesheet\" id=\"ss-blog\" type=\"text/css\" media=\"all\" href=\"https://www.appcelerator.com/wp-content/themes/appc-rwd/css/blog.css?ver=00717\">\n\t\n\t<!-- REDESIGN STYLES -->\n    <!-- Changing to use wp_enqueue_style() -->\n\t<!--<link rel=\"stylesheet\" id=\"ss-blog\" type=\"text/css\" media=\"all\" href=\"\">-->\n        <meta property=\"fb:pages\" content=\"20594753592\" />\n    \n\t<link rel=\"shortcut icon\" type=\"image/png\" href=\"https://www.appcelerator.com/wp-content/themes/appc-rwd/img/favicon.ico\">\n\t<link href=\"//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css\" rel=\"stylesheet\">\n\t<link rel=\"stylesheet\" href=\"https://www.appcelerator.com/wp-content/themes/appc-rwd/js/slimbox/css/slimbox2.css\" type=\"text/css\" media=\"screen\" />\n    <link rel=\"stylesheet\" href=\"https://www.appcelerator.com/wp-content/themes/appc-rwd/assets/fancybox/jquery.fancybox.css\" type=\"text/css\" media=\"screen\" />\n\t<!--[if IE]><![endif]-->\n\t<!--[if lt IE 9]><script src=\"/assets/js/html5shiv.js\"></script><![endif]-->\n\t\t\n<!-- All in One SEO Pack 2.2.7.5 by Michael Torbert of Semper Fi Web Design[408,448] -->\n<link rel=\"author\" href=\"https://plus.google.com/+appcelerator\" />\n\n<!-- /all in one seo pack -->\n\t\t<script type=\"text/javascript\">\n\t\t\twindow._wpemojiSettings = {\"baseUrl\":\"https:\\/\\/s.w.org\\/images\\/core\\/emoji\\/72x72\\/\",\"ext\":\".png\",\"source\":{\"concatemoji\":\"https:\\/\\/www.appcelerator.com\\/wp-includes\\/js\\/wp-emoji-release.min.js?ver=4.4.1\"}};\n\t\t\t!function(a,b,c){function d(a){var c,d=b.createElement(\"canvas\"),e=d.getContext&&d.getContext(\"2d\");return e&&e.fillText?(e.textBaseline=\"top\",e.font=\"600 32px Arial\",\"flag\"===a?(e.fillText(String.fromCharCode(55356,56806,55356,56826),0,0),d.toDataURL().length>3e3):\"diversity\"===a?(e.fillText(String.fromCharCode(55356,57221),0,0),c=e.getImageData(16,16,1,1).data.toString(),e.fillText(String.fromCharCode(55356,57221,55356,57343),0,0),c!==e.getImageData(16,16,1,1).data.toString()):(\"simple\"===a?e.fillText(String.fromCharCode(55357,56835),0,0):e.fillText(String.fromCharCode(55356,57135),0,0),0!==e.getImageData(16,16,1,1).data[0])):!1}function e(a){var c=b.createElement(\"script\");c.src=a,c.type=\"text/javascript\",b.getElementsByTagName(\"head\")[0].appendChild(c)}var f,g;c.supports={simple:d(\"simple\"),flag:d(\"flag\"),unicode8:d(\"unicode8\"),diversity:d(\"diversity\")},c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.simple&&c.supports.flag&&c.supports.unicode8&&c.supports.diversity||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener(\"DOMCont
      [INFO]  readyState: LOADING
      

      Expected Result

      • Android should not log received HTTP response errors (such as 404) to the Android log. Providing the HTTP error response to the onerror() listener is enough, like iOS. (It's up to the app developer to decide to log it.)
      • Android should set the "readyState" property to "DONE" after receiving HTTP response errors. This is to match our documentation and iOS behavior. (A response was successfully received after all, even though it might not be the response you wanted.)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                fmiao Feon Sua Xin Miao
                Reviewer:
                Joshua Quick
                Tester:
                Abir Mukherjee
              • Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-11110
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code