如何获得黑莓上的URL重定向 [英] How to get redirect url on blackberry

查看:222
本文介绍了如何获得黑莓上的URL重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我玩使用流式播放器黑莓视频网址。如果URL返回200状态code将其成功扮演。

I play a video url using streaming player on blackberry. If the url returns "200" status code it play successfully.

当我通过下面的网址,它返回302HTTP状态code.It不会在流播放器上播放。

When i pass the below url, it returns "302" http status code.It won't play on streaming player.

<一个href=\"http://belointr.rd.llnwd.net/KGW/ea398ac7b03a91c2ddf451f1fd7e3ef87f19da59_fl9.mp4?x-belo-vsect=kgw-basketball\" rel=\"nofollow\">http://belointr.rd.llnwd.net/KGW/ea398ac7b03a91c2ddf451f1fd7e3ef87f19da59_fl9.mp4?x-belo-vsect=kgw-basketball

当我检查状态code为302其说重定向URL。

When i check the statuscode for 302 its says redirect url.

当我通过浏览器上的网址,它会自动调用下面的重定向URL。

When i pass the url on browser, it calls automatically below the redirect url.

<一个href=\"http://belointr.vo.llnwd.net/kip0/_pxn=2+_pxI0=Ripod-h264+_pxL0=undefined+_pxM0=+_pxI1=A21907+_pxL1=begin+_pxM1=+_pxR1=13737+_pxK=20558/KGW/ea398ac7b03a91c2ddf451f1fd7e3ef87f19da59_fl9.mp4?x-belo-vsect=kgw-basketball\" rel=\"nofollow\">http://belointr.vo.llnwd.net/kip0/_pxn=2+_pxI0=Ripod-h264+_pxL0=undefined+_pxM0=+_pxI1=A21907+_pxL1=begin+_pxM1=+_pxR1=13737+_pxK=20558/KGW/ea398ac7b03a91c2ddf451f1fd7e3ef87f19da59_fl9.mp4?x-belo-vsect=kgw-basketball

如何获得重定向URL编程黑莓?

How can i get the redirect url programatically on blackberry.?

请帮我。

推荐答案

在响应的头,检索头位置的值,它包含了重定向URL。这是一个标准的HTTP协议

In the headers of the response, retrieve the value of the header 'Location', it contains the redirect url. This is standard in HTTP protocol

编辑:如何获得位置头真正的快速样品(可写了很多更好,更安全)

Real quick sample on how to get the location header (could be written a lot better and safer)

    URL url = new URL("http://some.url");
    int responseCode = -1;
    while (responseCode != 200) {
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        responseCode = conn.getResponseCode();
        if (responseCode > 299 && responseCode < 400) {
            url = new URL(conn.getHeaderField("Location"));
        }
    }

这篇关于如何获得黑莓上的URL重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆