跟随客户端的图像HTTP请求的重定向 [英] Follow redirects for image HTTP request, client-side

查看:95
本文介绍了跟随客户端的图像HTTP请求的重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道这个链接:

http://media.photobucket.com/image/graphics/PennilessTeacher/Graphics/monster.jpg?o=8

重定向到此链接:

http://i1133.photobucket.com/albums/m581/PennilessTeacher/Graphics/monster.jpg

好吧,假设我有:

<img src='http://media.photobucket.com/image/graphics/PennilessTeacher/Graphics/monster.jpg?o=8' width='blah' height = 'blah'/>

对图像URL的请求将被重定向。我想知道结束网址。所以在这种情况下,它将是 http://i1133.photobucket.com/albums/m581/PennilessTeacher/Graphics/monster.jpg

The request to the image URL will be redirected. I want to know the end URL. So in this case, it would be http://i1133.photobucket.com/albums/m581/PennilessTeacher/Graphics/monster.jpg.

我之前问过一个关于获取跨域图像请求状态代码的问题,如果没有服务器端脚本执行 http 请求。

I previously asked a question about fetching the status code of a cross domain image request, which seems to be impossible without a server side script doing the http request.

服务器端脚本在这里是不可能的。我需要在客户端处理请求,因为image元素指向的某些站点需要一些位于客户端的特定cookie,我显然无法自助,因为它们完全不同域。如果这有任何意义......

Server side scripts are out of the question here. I need the request to be processed on the client's side, as some of the sites the image element will be pointing to require some specific cookies that sit on the client side, which I obviously cannot help myself to as they're for a completely different domain. If that makes any sense...

任何客户端语言都可以。我是否知道。

Any client side language will do. Whether I know it or not.

建议人们?或者我完全搞砸了?

Suggestions people? Or am I totally screwed?

推荐答案

使用客户端脚本无法获取该信息。 DOM中唯一的信息是最初请求的URI。

There is no way to get that information using client side scripting. The only information in the DOM is the originally requested URI.

(如果可能,则可能泄露信息。例如,如果 http:// example.com/me 重定向到 http://example.com/users/username 并将Bob的网站上的Alice用户名暴露给Malory(谁跑了当Alice访问该网站时,网站上有< img src =http://example.com/me> ...或者它可能会重定向到 http://cdn.example.com/alices/private/content/protected/by/time/limited/key/h4io3foiu32if390f490 让Malory访问Alice的私人内容。

(If it was possible then information could be leaked. e.g. if http://example.com/me redirected to http://example.com/users/username and expose Alice's username on Bob's site to Malory (who ran the website with <img src="http://example.com/me"> on it when Alice visited that site … or perhaps it might redirect to http://cdn.example.com/alices/private/content/protected/by/time/limited/key/h4io3foiu32if390f490 and let Malory get access to Alice's private content).

这篇关于跟随客户端的图像HTTP请求的重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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