1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-23 01:25:13 +00:00
QB64-PE/tests/compile_tests/http/read_example.bas
Matthew Kilgore 12c9c35db5 Add _StatusCode command for HTTP handles
The _StatusCode command returns the status code on the HTTP response
when given a HTTP handle from _OpenClient().
2022-11-20 04:04:02 -05:00

32 lines
525 B
QBasic

$Unstable:Http
$Console:Only
h& = _OpenClient("https://www.example.com")
Print h&
length~& = LOF(h&)
result$ = ""
While Not Eof(h&)
_Limit 100
GET #h&, , s$
result$ = result$ + s$
Wend
' Strip off the trailing slash if it's there to make the result consistent
url$ = _ConnectionAddress$(h&)
If MID$(url$, LEN(url$), 1) = "/" Then
url$ = Left$(Url$, LEN(url$) - 1)
End If
Print "Content-Length: "; length~&
Print "Url: "; url$
Print "Status Code: "; _StatusCode(h&)
Print
Print result$
Close h&
System