Created
December 31, 2013 15:10
-
-
Save cflove/8198147 to your computer and use it in GitHub Desktop.
Grab page over http, like in cfhttp. Had to fetch directory index from an old Fedora 4 box and cfhttp did not return it. This seems to do the trick.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <cffunction name="httppage" access="public" returnType="any" output="no"> | |
| <cfargument name ="source" type="any" required="true"/> | |
| <cfset local.urlconnection = createObject("java", "java.net.URL").init(javaCast('string',arguments.source))> | |
| <cfset local.Connection = local.urlconnection..openConnection() /> | |
| <cfset local.Connection.connect() /> | |
| <cfset local.InputStreamReader = createObject("java", "java.io.InputStreamReader").init(local.Connection.getInputStream()) /> | |
| <cfset local.BufferedReader = createObject("java", "java.io.BufferedReader").init(local.InputStreamReader) > | |
| <cfset local.Page = arrayNew(1) /> | |
| <cfloop condition="#yesNoFormat(local.BufferedReader.ready())#"> | |
| <cfset arrayAppend(local.Page,local.BufferedReader.readLine())> | |
| </cfloop> | |
| <cfreturn local.Page> | |
| </cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment