HTTP: Difference between revisions
Content added Content deleted
mNo edit summary |
(Initial FutureBasic task solution added) |
||
Line 1,194: | Line 1,194: | ||
<syntaxhighlight lang="frink"> |
<syntaxhighlight lang="frink"> |
||
print[read["http://frinklang.org/"]] |
print[read["http://frinklang.org/"]] |
||
</syntaxhighlight> |
|||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
include "NSLog.incl" |
|||
#plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES} |
|||
local fn URLSessionHandler( session as URLSessionRef, dta as CFDataRef, response as URLResponseRef, err as ErrorRef, userData as ptr ) |
|||
if ( fn HTTPURLResponseStatusCode( (HTTPURLResponseRef)response ) == 200 ) |
|||
NSLog( @"%@", fn StringWithData( dta, NSUTF8StringEncoding ) ) |
|||
else |
|||
NSLog( @"%@", fn ErrorLocalizedDescription( err ) ) |
|||
end if |
|||
NSLogScrollToTop |
|||
end fn |
|||
local fn URLSessionWithGetRequest( path as CFStringRef ) |
|||
CFURLRef url = fn URLWithString( path ) |
|||
MutableURLRequestRef urlRequest = fn MutableURLRequestWithURL( url ) |
|||
MutableURLRequestSetHTTPMethod( urlRequest, @"HTTP" ) |
|||
URLSessionRef session = fn URLSessionSharedSession |
|||
URLSessionDataTaskRef task = fn URLSessionDataTaskWithRequestCompletionHandler( session, urlRequest, @fn URLSessionHandler, NULL ) |
|||
URLSessionTaskResume( task ) |
|||
end fn |
|||
fn URLSessionWithGetRequest( @"http://rosettacode.org" ) |
|||
HandleEvents |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||