Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ColdFusion中的基本身份验证_Coldfusion_Basic Authentication - Fatal编程技术网

ColdFusion中的基本身份验证

ColdFusion中的基本身份验证,coldfusion,basic-authentication,Coldfusion,Basic Authentication,我正在尝试连接到需要基本身份验证的第三方供应商。我基本上需要下载html/js/css并在我的网站上查看内容。我已经可以使用下面的代码连接到该站点。问题是,下面的内容引用的是与其他域相关的js和css,它们本身也需要基本的身份验证。我已尝试将“resolveUrl”设置为true,这似乎是正确的步骤,但我无法通过基本身份验证块。我很感激在这件事上能得到的帮助 <cfscript> httpService = new http(); httpService.setUR

我正在尝试连接到需要基本身份验证的第三方供应商。我基本上需要下载html/js/css并在我的网站上查看内容。我已经可以使用下面的代码连接到该站点。问题是,下面的内容引用的是与其他域相关的js和css,它们本身也需要基本的身份验证。我已尝试将“resolveUrl”设置为true,这似乎是正确的步骤,但我无法通过基本身份验证块。我很感激在这件事上能得到的帮助

<cfscript>
    httpService = new http();

    httpService.setURL("https://example.com");
    httpService.setMethod("GET");
    httpService.setUsername("someusername");
    httpService.setPassword("somepassword");
    httpService.setResolveUrl(true);

    prefix = httpService.send().getPrefix();
    fileContent = prefix.fileContent;

    writeOutput(fileContent);
</cfscript>

httpService=newhttp();
httpService.setURL(“https://example.com");
setMethod(“GET”);
setUsername(“someusername”);
httpService.setPassword(“somepassword”);
httpService.setResolveUrl(true);
prefix=httpService.send().getPrefix();
fileContent=prefix.fileContent;
writeOutput(文件内容);

ResolveURL是否按预期运行?你的意图是什么?是否要从文档中收集URL,以便知道从何处收集

有许多关于将文本中的链接转换为超链接的主题。您可以使用
ReMatch()
轻松地调整它并收集数组

您甚至可以使用Adobe的示例:

result = REMatch("https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?", cfhttp.filecontent);
我还没有测试过这个,但是我觉得这个改变可能会奏效

result = REMatch("https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\.js|\.css.|\.other|\.ext|\.you|\.wnt|\.hre)(\?\S+)?)?)?", cfhttp.filecontent);
或者简单地说

result = REMatch("http[s]?://([^\s"">])*(\.js|\.css.|\.other|\.ext|\.you|\.wnt|\.hre)([^\s"">])*", cfhttp.filecontent);
您必须在扩展名中的
前面加一个
\
,因为
是正则表达式中的一个特殊字符(它是一个通配符,表示任何字符)

结果返回请求中每个匹配项的数组。您可以使用它,以便它只过滤以特定扩展名结尾的文件

在得到结果数组之后,我会进行一些处理以确保没有任何重复的URL,然后在数组上进行cfloop并对内容进行dl

初级蜘蛛:)