Skip to content

API UO HTTP_Header en

Codex edited this page Oct 3, 2026 · 1 revision

UO.HTTP_Header

Русский · English · Українська · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

UO.HTTP_Get · UO.HTTP_Post · UO.HTTP_Body · UO.HTTP_Header

ClassicUO • Runtime API

Reads this script's last HTTP response headers, such as Content-Type. These are neither the response body, request headers, nor a numeric HTTP status.

Exact syntax

UO.HTTP_Header() -> Any

Parameters

No parameters.

Returns

String — Name: value lines separated by CRLF. Empty before the first request or after a network failure. No HTTP/1.1 200 OK status line; no separate status-code command is exposed. Header order and name casing are not guaranteed.

Behavior

  • The last response belongs to the current script runtime. Its next GET/POST replaces it; other concurrent scripts do not. It is not saved in the profile. Copy body and headers to local variables before another request if needed.
  • GET/POST wait in the executing script thread. One 20-second deadline covers the request and body read. Stopping the script cancels the wait; HTTP_Body/HTTP_Header never wait. The whole response is buffered in memory even with File; this is not streaming for large downloads.
  • Response charset controls text decoding; missing/unknown charset falls back to UTF-8. HTTP 4xx/5xx bodies are read too. A network failure/timeout logs an error and empties body and headers; Try/Catch does not replace checking the expected response. Script cancellation propagates. Local file-write or argument errors may be caught by Try/Catch.
  • HTTP_Header combines response and content headers, including after binary GET. Compare names case-insensitively. Content-Type is the server's claim, not content validation; never execute downloaded text as code.

Internal functions: from call to result

These are actual client stages, not extra UO commands. GET/POST call HttpRequest; HTTP_Body/HTTP_Header only read its result within their runtime.

1. ExecuteClientApiCompatibility

HTTP_Header combines response and content headers, including after binary GET. Compare names case-insensitively. Content-Type is the server's claim, not content validation; never execute downloaded text as code.

String — Name: value lines separated by CRLF. Empty before the first request or after a network failure. No HTTP/1.1 200 OK status line; no separate status-code command is exposed. Header order and name casing are not guaranteed.

Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionApiUO.cs; function ExecuteClientApiCompatibility.

These are actual client stages, not extra UO commands. GET/POST call HttpRequest; HTTP_Body/HTTP_Header only read its result within their runtime.

Examples

Read Content-Type by name

# Read Content-Type by name
#
# Reads this script's last HTTP response headers, such as Content-Type. These are neither the
# response body, request headers, nor a numeric HTTP status.
#
# String — Name: value lines separated by CRLF. Empty before the first request or after a
# network failure. No HTTP/1.1 200 OK status line; no separate status-code command is exposed.
# Header order and name casing are not guaranteed.

SUB Main()
    # The complete ReadHeader helper matches a line-start name case-insensitively, trims the value
    # and returns an empty string if absent. A result could be application/json; charset=utf-8.
    # The example.com URLs are illustrative and do not provide this service. Replace them with your
    # endpoints; running an example performs real HTTP requests. No game actions are performed.

    UO.HTTP_Get("https://example.com/basic-status")
    Return ReadHeader(UO.HTTP_Header(), "Content-Type")
END SUB

Function ReadHeader(headers, name)
    Dim marker = Chr(13) & Chr(10) & LCase(name) & ":"
    Dim text = Chr(13) & Chr(10) & headers & Chr(13) & Chr(10)
    Dim start = InStr(1, LCase(text), marker)
    If start = 0 Then
        Return ""
    End If
    start += Len(marker)
    Dim finish = InStr(start, text, Chr(13) & Chr(10))
    Return Trim(Mid(text, start, finish - start))
End Function

Parameter and execution notes:

  • The complete ReadHeader helper matches a line-start name case-insensitively, trims the value and returns an empty string if absent. A result could be application/json; charset=utf-8.
  • The example.com URLs are illustrative and do not provide this service. Replace them with your endpoints; running an example performs real HTTP requests. No game actions are performed.

Check for a JSON marker

# Check for a JSON marker
#
# Reads this script's last HTTP response headers, such as Content-Type. These are neither the
# response body, request headers, nor a numeric HTTP status.
#
# String — Name: value lines separated by CRLF. Empty before the first request or after a
# network failure. No HTTP/1.1 200 OK status line; no separate status-code command is exposed.
# Header order and name casing are not guaranteed.

SUB Main()
    # The case-insensitive application/json search returns True/False. It only checks text across
    # all headers. For an exact value use ReadHeader from the first example, then validate the body
    # with JsonParse.
    # The example.com URLs are illustrative and do not provide this service. Replace them with your
    # endpoints; running an example performs real HTTP requests. No game actions are performed.

    UO.HTTP_Get("https://example.com/basic-status")
    Dim headers = UO.HTTP_Header()
    Return InStr(1, LCase(headers), "application/json") > 0
END SUB

Parameter and execution notes:

  • The case-insensitive application/json search returns True/False. It only checks text across all headers. For an exact value use ReadHeader from the first example, then validate the body with JsonParse.
  • The example.com URLs are illustrative and do not provide this service. Replace them with your endpoints; running an example performs real HTTP requests. No game actions are performed.

Read binary-download headers

# Read binary-download headers
#
# Reads this script's last HTTP response headers, such as Content-Type. These are neither the
# response body, request headers, nor a numeric HTTP status.
#
# String — Name: value lines separated by CRLF. Empty before the first request or after a
# network failure. No HTTP/1.1 200 OK status line; no separate status-code command is exposed.
# Header order and name casing are not guaranteed.

SUB Main()
    # Supplying a stream does not prevent reading headers. Main returns them all; the body is in
    # data, while HTTP_Body is empty after this GET form.
    # The example.com URLs are illustrative and do not provide this service. Replace them with your
    # endpoints; running an example performs real HTTP requests. No game actions are performed.

    Dim data = MemoryStream()
    Using data
        UO.HTTP_Get("https://example.com/route-data.bin", data)
        Dim headers = UO.HTTP_Header()
        Return headers
    End Using
END SUB

Parameter and execution notes:

  • Supplying a stream does not prevent reading headers. Main returns them all; the body is in data, while HTTP_Body is empty after this GET form.
  • The example.com URLs are illustrative and do not provide this service. Replace them with your endpoints; running an example performs real HTTP requests. No game actions are performed.

Clone this wiki locally