我在从我的应用程序从互联网下载二进制文件(zip文件)时遇到问题.我必须使用基本访问身份验证来授权访问文件,但服务器响应始终是HTTP/1.0 400错误请求.
String authentication = this._login+":"+this._pass;
String encoding = Base64.encodeToString(authentication.getBytes(), 0);
String fileName = "data.zip";
URL url = new URL("http://10.0.2.2/androidapp/data.zip");
HttpURLConnection ucon = (HttpURLConnection) url.openConnection();
ucon.setRequestMethod("GET");
ucon.setDoOutput(true);
ucon.setRequestProperty ("Authorization", "Basic " + encoding);
ucon.connect();
/*
* Define InputStreams to read from the URLConnection.
*/
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
/*
* Read bytes to the Buffer until there is nothing more to read(-1).
*/
ByteArrayBuffer bab = new ByteArrayBuffer(50);
int current = 0;
while ((current = …Run Code Online (Sandbox Code Playgroud) 我在找了一段时间,但仍然找不到从GnomeShell扩展代码中调用python函数的任何书面方法。有可能这样做吗?