Basic Authentication in ColdFusion -
i'm trying connect 3rd party vendor requires basic authentication. need download html/js/css , view content on website. can connect site using code below. problem content below references js , css relative other domain , require basic authentication themselves. have tried setting 'resolveurl' true seems right step, cannot passed basic authentication block. appreciate help can on this.
<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>
is resolveurl doing expected? intent? gather urls document know collect from?
there many many topics on converting links within text hyperlinks. adapt , collect array using rematch()
.
you utilize adobe's example:
result = rematch("https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\s+)?)?)?", cfhttp.filecontent);
i haven't tested but, sense alter might work
result = rematch("https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\.js|\.css.|\.other|\.ext|\.you|\.wnt|\.hre)(\?\s+)?)?)?", cfhttp.filecontent);
or simple like
result = rematch("http[s]?://([^\s"">])*(\.js|\.css.|\.other|\.ext|\.you|\.wnt|\.hre)([^\s"">])*", cfhttp.filecontent);
you have prefix .
in extensions \
because .
special character in regex (it's wildcard meaning character)
result returns array of every match within request. play filters files ending in extensions.
after getting results array, i'd crunching create sure didn't have duplicate urls , cfloop on array , dl content.
a rudimentary spider :).
coldfusion basic-authentication
No comments:
Post a Comment