我们在我的工作场所使用websense互联网过滤器。我有一个尝试从互联网上检索信息的应用程序。
在我的客户端机器上,我必须手动使用websense进行身份验证(例如,打开firefox并提供我的用户名/密码),否则我的应用程序在尝试下载时会出现错误。
错误消息为:
HTTP/1.0 302 Moved.有没有人知道一种通过代码验证websense的方法?任何语言的例子都是受欢迎的--我使用的是Delphi和Indy的TIdHTTP组件。
发布于 2009-08-04 15:20:31
回答我自己的问题;这是对我有效的方法。
仅当您希望身份验证允许MSN / Live messenger通过时,才需要自定义用户代理字符串,as described under "notes" at the end of this article.
在命令行应用程序中:
uses
... IdHTTP ...;
...
var
httpGetter: TIdHTTP;
...
httpGetter.Request.Username := username;
httpGetter.Request.Password := password;
httpGetter.HandleRedirects := True;
httpGetter.Request.BasicAuthentication := True;
//custom useragent required to let live messenger work
httpGetter.Request.UserAgent := 'MSN Explorer/9.0 (MSN 8.0; TmstmpExt)';
httpGetter.Get(url,MS);
...发布于 2009-08-04 15:16:52
我会尝试HTTP身份验证
http://en.wikipedia.org/wiki/Basic_access_authentication
https://stackoverflow.com/questions/1227874
复制相似问题