HttpURLConnection 收到错误响应

HttpURLConnection getting wrong response

嗯,我的 php 文件包含简单代码 <?php echo "hello there" ?> 每当我尝试使用 HttpURLConnection.getInputStream(); 读取文件时,它 returns

<html>

<body>
    <script type="text/javascript" src="/aes.js"></script>
    <script>
        function toNumbers(d) {
            var e = [];
            d.replace(/(..)/g, function(d) {
                e.push(parseInt(d, 16))
            });
            return e
        }

        function toHex() {
            for (var d = [], d = 1 == arguments.length && arguments[0].constructor == Array ? arguments[0] : arguments, e = "", f = 0; f < d.length; f++) e += (16 > d[f] ? "0" : "") + d[f].toString(16);
            return e.toLowerCase()
        }
        var a = toNumbers("f655ba9d09a112d4968c63579db590b4"),
            b = toNumbers("98344c2eee86c3994890592585b49f80"),
            c = toNumbers("b1fd294057e960f23314aeedeca32e65");
        document.cookie = "__test=" + toHex(slowAES.decrypt(c, 2, a, b)) + "; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";
        location.href = "http://classreminder.rf.gd/test.php?i=1";
    </script>
    <noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
</body>

</html>

我只想读取原始文件..只有 "hello there"..没有别的..怎么做?

无论您使用什么,HttpURLConnection 或 Web 浏览器,php 文件在下载到客户端之前总是在 服务器端 执行,在这种情况下,您的 phone。您无法在客户端执行任何操作来读取原始 php 文件。

在服务器端,您可以将 *.php 文件重命名为 *.html 然后您将始终获得原始 php 文件。但我不认为这是你想要的......如果你想能够从 phone 读取或编辑 php 文件,你可以使用 ftp 或 ssh.

老问题,早就解决了。但对于面临同样问题的人来说,这里有一些东西: 发现我的 HttpURLConnection 和我的 php 文件都是正确的。但是服务器在执行任何文件之前 运行 浏览器检查。因此我无法到达 php 文件端点。我只是更改了主机,它解决了我的问题。