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