HTTP: Difference between revisions

Undo revision 315481 by WdeCvfYlmB (talk)
(Undo revision 315492 by WdeCvfYlmB (talk))
(Undo revision 315481 by WdeCvfYlmB (talk))
Line 1,713:
=={{header|Ruby}}==
The simple way loads the entire content into memory, then prints it.
<lang ruby>require 'open-uri'
 
print open("http://rosettacodewww.w3.org/Home.html") {|f| f.read}
<lang ruby>
|f| f.read
require 'open-uri'
}</lang ruby>
 
print open("http://rosettacode.org") {|f| f.read}
</lang>
 
If the content might be large, the better way uses FileUtils.copy_stream.
<lang ruby>require 'fileutils'
 
<lang ruby>
require 'fileutils'
require 'open-uri'
open("http://www.w3.org/Home.html") {
 
open("http://rosettacode.org/") { |f| FileUtils.copy_stream(f, $stdout)}
}</lang>
 
=={{header|Run BASIC}}==
Line 1,924 ⟶ 1,919:
Const HTTPREQUEST_PROXYSETTING_PROXY As Long = 2
#Const USE_PROXY = 1
Set HttpReq = New WinHttp.WinHttpRequest
HttpReq.Open "GET", "http://www.w3rosettacode.org/Homerobots.htmltxt"
#If USE_PROXY Then
HttpReq.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, "my_proxy:80"
#End If
HttpReq.SetTimeouts 1000, 1000, 1000, 1000
HttpReq.Send
Debug.Print HttpReq.ResponseText
End Sub</lang>
 
10,333

edits