gpt4 book ai didi

android - 响应 301 永久移动

转载 作者:可可西里 更新时间:2023-11-01 16:40:22 25 4
gpt4 key购买 nike

我曾经得到以下对 php 请求的响应

响应:

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

我的代码:

 URL url = new URL("http://myappdemo.com/payumoney/payUmoneyHashGenerator.php");

// get the payuConfig first
String postParam = postParams[0];

byte[] postParamsByte = postParam.getBytes("UTF-8");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setInstanceFollowRedirects(false);
conn.setRequestProperty("Content-Length",
String.valueOf(postParamsByte.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postParamsByte);

InputStream responseInputStream = conn.getInputStream();
StringBuffer responseStringBuffer = new StringBuffer();
byte[] byteContainer = new byte[1024];
for (int i; (i = responseInputStream.read(byteContainer)) != -1; ) {
responseStringBuffer.append(new String(byteContainer, 0, i));
}

Log.e("tag", "doInBackground: "+ responseStringBuffer.toString());

也试过 Volley 响应是

BasicNetwork.performRequest: Unexpected response code 301 for http://myappdemo.com/payumoney/payUmoneyHashGenerator.php

.

请帮帮我。提前致谢。

最佳答案

301 Moved Permanently 用于永久 URL 重定向。应更新使用收到响应的 URL 的当前链接。尝试在您的链接中使用 https://

使用 URL url = new URL("https://myappdemo.com/payumoney/payUmoneyHashGenerator.php");

关于android - 响应 301 永久移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48167467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com