Osy#the first language built for agents
Agents firstAgentic appsWorkflowsDurable Execution — built inSecurityTestingThe editorThe UI modelOne program

Reference / HTTP

HttpResponse

class HttpResponse { int StatusCode; string Body; bool IsSuccess; }

The result of an `Http.*` call. Carries the HTTP status code, the response body as text, and a convenience `IsSuccess` flag for 2xx. A non-2xx status is a normal value here, not an exception — you branch on it.

stable1 example compiled by CIhttpnetworktype

Summary#

HttpResponse is what every Http.* verb (Http.*) returns. It has three fields:

FieldTypeMeaning
StatusCodeintThe HTTP status code — 200, 404, 500, …
BodystringThe response body as UTF-8 text
IsSuccessbooltrue when the status is in the 2xx range

A non-2xx response is a normal return, so you inspect it rather than catch an error:

use Osyrin.Http;

var r = Http.Get(url);
if (r.IsSuccess) {
  Process(r.Body);
} else {
  Log("fetch failed with " + r.StatusCode);
}

Signature#

class HttpResponse {
  int StatusCode;
  string Body;
  bool IsSuccess;
}

The type enters scope with the same dependency that enables the facade — use Osyrin.Http;. You rarely name it explicitly: var r = Http.Get(url); infers it.

Description#

Body is always text. When the endpoint returns JSON, parse Body with the JSON surface; HttpResponse doesn't assume a format — it hands you the bytes as a string and the status to decide what to do with them.

IsSuccess is exactly 200 ≤ StatusCode < 300. It's a convenience for the common "did it work?" branch; when you care about a specific code (a 429 to back off, a 404 to treat as absent), read StatusCode directly.

Examples#

Distinguish "not found" from a real failure:

app Shop {
  model "model/**/*.osy";
  use Osyrin.Http;       // the manifest dependency that makes `Http.*` available
}

string FetchOrEmpty(string url) {
  var r = Http.Get(url);
  if (r.StatusCode == 404) return "";        // absent — expected
  if (!r.IsSuccess) return "";                // some other failure
  return r.Body;
}

See also#

  • Http.* — the Http.Get/Post/Put/Delete verbs that return this type

Related

Http.*

Make an outbound HTTP call to a URL you build at runtime — a webhook, a third-party API, a discovered endpoint…