http staus 301 for some urls
My app is an online radio,When I am trying to connect my app to http server for some urls the 'httpstatus' returned is 301.But it perfeclty ok for some other urls in the same http server. The method I used :
public InputStream getHttpConnectionStream(String url){
String newUrl= url+getUrlAppend();
StreamConnection streamConnection=null;
InputStream inputStream=null;
InputStream ips = null;
String result="";
try {
streamConnection=(StreamConnection)Connecto开发者_开发技巧r.open(newUrl,Connector.READ);
HttpConnection httpConnection=(HttpConnection)streamConnection;
httpConnection.setRequestMethod(HttpConnection.POST);
int httpStatus=httpConnection.getResponseCode();
if(httpStatus<HttpConnection.HTTP_OK){ //==HttpConnection.HTTP_OK
inputStream = httpConnection.openInputStream();
ips=inputStream;
return ips;
}
} catch (IOException e) {
}
return ips;
}
Here getUrlAppend() is method which returns a string specific to the way in which the app connect to server.If httpStatus is 301 I got only null InputStream .
How can I resolve the http status,Can any one help me?
According to the HTTP/1.1 specification, a 301 status code indicates that the item you are attempting to locate has permanently moved. The server should be providing you the new location in the HTTP response header. Your application will need to parse the response header for the new location and execute a new connection to that new location.
精彩评论