mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-09 12:50:17 +00:00
The _StatusCode command returns the status code on the HTTP response when given a HTTP handle from _OpenClient().
31 lines
525 B
QBasic
31 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
|