HTTP: Difference between revisions

Content deleted Content added
Rahul (talk | contribs)
Rahul (talk | contribs)
Line 55: Line 55:
link cfunc
link cfunc
procedure main(args)
procedure main(args)

get(args[1], args[2], args[3])
get(args[1])
end
end
procedure get(host, port, url)
procedure get(url)
local f
local f, host, port, path
url ? {
="http://" | ="HTTP://"
host := tab(upto(':/') | 0)
if not (=":" & (port := integer(tab(upto('/'))))) then port := 80
if pos(0) then path := "/" else path := tab(0)
}
write(host)
write(path)
f := tconnect(host, port) | stop("Unable to connect")
f := tconnect(host, port) | stop("Unable to connect")
writes(f, "GET ", url ," HTTP/1.0\r\n\r\n")
writes(f, "GET ", path | "/" ," HTTP/1.0\r\n\r\n")
while write(read(f))
while write(read(f))
end
end

Using it
Using it
|icon req.icn www.rosettacode.org 80 /
|icon req.icn http://www.rosettacode.org


=={{header|Java}}==
=={{header|Java}}==