Created
November 10, 2012 18:15
-
-
Save legumbre/4051995 to your computer and use it in GitHub Desktop.
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
objc = require("tlc") | |
ffi= require "ffi" | |
-- objc.loadFramework("AppKit") | |
-- objc.loadFramework("CoreFoundation") | |
-- objc.loadFramework("Foundation") | |
-- objc.loadFramework("Carbon") | |
pool = objc.NSAutoreleasePool:new() | |
aUrl = objc.NSURL:URLWithString(objc.NSStr("http://10.10.10.1/")) | |
request = objc.NSURLRequest:requestWithURL(aUrl) | |
resp = objc.NSURLResponse:new() | |
resp_p = ffi.new("id[1]", resp) | |
response = objc.NSURLConnection:sendSynchronousRequest_returningResponse_error(request, resp_p, nil) | |
print(objc.NSString:stringWithUTF8String(response:bytes())) | |
K> print(objc.NSString:stringWithUTF8String(response:bytes())) | |
<html><body><h1>It works!</h1> | |
<p>This is the default web page for this server.</p> | |
<p>The web server software is running but no content has been added, yet.</p> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment