Skip to content
Skills Library
Programming · Building & coding

web-requests

/web-requests

Web request framework for HTTP operations. Use when making API calls, HTTP/REST requests, fetching data from server, downloading content via IWebRequestController, parsing responses, building URLs with URLBuilder, signing requests with Web3 auth chains, or configuring retry policies.

Licence
Apache-2.0
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Web request framework for HTTP operations. Use when making API calls, HTTP/REST requests, fetching data from server, downloading content via IWebRequestController, parsing responses, building URLs with URLBuilder, signing requests with Web3 auth chains, or configuring retry policies.

Original author description

Web request framework for HTTP operations. Use when making API calls, HTTP/REST requests, fetching data from server, downloading content via IWebRequestController, parsing responses, building URLs with URLBuilder, signing requests with Web3 auth chains, or configuring retry policies.

How it works

  1. Sources
  2. IWebRequestController API
  3. CommonArguments
  4. Response Parsing
  5. Request Signing
  6. Retry Policy
  7. URL Utilities
  8. Design Notes
Original SKILL.md headings · 183 lines, 611 words
SKILL.md preview
---
name: web-requests
description: "Web request framework for HTTP operations. Use when making API calls, HTTP/REST requests, fetching data from server, downloading content via IWebRequestController, parsing responses, building URLs with URLBuilder, signing requests with Web3 auth chains, or configuring retry policies."
user-invocable: false
---

# Web Requests

## Sources

- `docs/web-requests-framework.md` — Custom web request framework
- `docs/web3-authentication.md` — Web3 authentication, identity, and signing

---

## IWebRequestController API

The primary interface for all HTTP operations:

```csharp
// GET — strongly typed response
var response = await webRequestController.GetAsync(commonArguments, ct, ReportCategory.AUTHENTICATION);

// POST
var response = await webRequestController.PostAsync(commonArguments, body, ct, ReportCategory.MY_CATEGORY);

// GET texture
var response = await webRequestController.GetTextureAsync(commonArguments, ct, ReportCategory.TEXTURES);
```

## CommonArguments

```csharp
var commonArguments = new CommonArguments(
    url,                    // URLAddress — required
    attemptsCount: 3,       // Default: 3 (1 initial + 2 retries)
    timeout: 0              // Default: 0 (no timeout)
);
```

## Response Parsing

Use `GenericDownloadHandlerUtils` for response deserialization:

```csharp
// Overwrite existing object from JSON (avoids allocation)
await response.OverwriteFromJson(existingObject);

// Create new object from JSON
MyDto dto = await response.CreateFromJson<MyDto>();

// Create from Newtonsoft JSON (for complex types)
MyDto dto = await response.CreateFromNewtonsoftJsonAsync<MyDto>();

// Get raw bytes
byte[] data = await response.GetDataCopy();
```

### Code Example — URL Building + Request + Deserialization

From `TokenFileAuthenticator.cs`:

```csharp
private async UniTask<IWeb3Identity> LoginAsync(CancellationToken ct)
{
    string token = contentResult.Value;

    // Build URL with URLBuilder
    urlBuilder.Clear();
    urlBuilder.AppendDomain(URLDomain.FromString(authApiUrl))
              .AppendPath(new URLPath($"identities/{token}"));

    var commonArguments = new CommonArguments(urlBuilder.Build());

    // GET request with Newtonsoft JSON deserialization
    IdentityAuthResponseDto json = await webRequestController
        .GetAsync(commonArguments, ct, ReportCategory.AUTHENTICATION)
        .CreateFromNewtonsoftJsonAsync<IdentityAuthResponseDto>();

    // Use response data
    var authChain = AuthChain.Create();
    foreach (AuthLink authLink in json.identity.authChain)
        authChain.Set(authLink);
    // ...
}
```

## Request Signing

For authenticated requests, use `WebRequestSignInfo`:

```csharp
// Create sign info with IWeb3Authenticator
var signInfo = new WebRequestSignInfo(signUrl);

// The framework adds x-identity-auth-chain-N headers automatically
var response = await webRequestController.GetAsync(commonArguments, ct, reportCategory, signInfo);
```

### Auth Chain Construction

```csharp
// Sign a payload
AuthChain authChain = identity.Sign("payload");

// Manually set headers (if not using framework signing)
int i = 0;
foreach (AuthLink link in authChain)
{
    request.SetRequestHeader($"x-identity-auth-chain-{i}", link.ToJson());
    i++;
}
```

### Identity Access

```csharp
// Get user address
string address = web3IdentityCache.Identity.Address;

// Check if authenticated
if (web3IdentityCache.Identity != null) { /* ... */ }
```

## Retry Policy

### Default Behavior

- Only GET requests are idempotent by default
- Signed requests are NOT idempotent (won't retry)
- Default: up to 2 retries with exponential backoff (1s base, 3x multiplier)

### Error Code Qualification

| Code | Retry? | Reason |
|------|--------|--------|
| 400 | No | Bad Request |
| 401 | No | Unauthorized |
| 403 | No | Forbidden |
| 404 | No | Not Found |
| 408 | Yes | Request Timeout |
| 429 | Yes | Too Many Requests |
| 500 | Yes | Internal Server Error |
| 502 | Yes | Bad Gateway |
| 503 | Yes | Service Unavailable |
| 504 | Yes | Gateway Timeout |
| 511 | No | Network Auth Required |

### Forcing Retries

```csharp
// Force retry even for non-idempotent requests
RetryPolicy.Enforce()
```

### JS API

No retries unless `Retry-Delay` header present on 429/503.

## URL Utilities

Use typed URL structures from `URLHelpers`:

```csharp
// Domain
var domain = URLDomain.FromString("https://api.example.com");

// Address
var address = URLAddress.FromString("https://api.example.com/v1/users");

// Builder — chain construction
var builder = new URLBuilder();
builder.Clear();
builder.AppendDomain(domain)
       .AppendPath(new URLPath("v1/users"))
       .AppendParameter(new URLParameter("page", "1"));
URLAddress url = builder.Build();
```

## Design Notes

- The framework is designed to be **allocation-free** — value types throughout
  - **Why:** HTTP requests happen frequently in hot paths; GC pressure from request objects would cause frame hitches in the Unity game loop.
- `WebRequestHeadersInfo` uses pooling for header storage
- `IWebRequestsAnalyticsContainer` tracks ongoing requests for analytics
- Signed requests are **not retried** by default
  - **Why:** Auth chains are time-sensitive — replaying a signed request after delay would fail validation, so retrying is wasteful and potentially confusing for error handling.

Versions

The database has no other skills named web-requests.

Database snapshot: 13.11.2026 · package version a030f08dd82e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100bun-http-server
    Use when building HTTP servers with Bun.serve, handling requests/responses, implementing routing, creating REST APIs, or configuring fetch handlers.
  • 100golang-api-server
    Build HTTP services, REST APIs, and middleware in Go. Use when building Go HTTP servers, REST APIs, or custom middleware.
  • 100httpie
    Use this skill whenever the user wants to make HTTP requests, test APIs, call REST endpoints, debug web services, or interact with any HTTP/HTTPS API using the HTTPie CLI tool (`http` command). Trigger this skill for any request involving: sending GET/POST/PUT/PATCH/DELETE…
  • 100flutter-handling-http-and-json
    Executes HTTP requests and handles JSON serialization in a Flutter app. Use when integrating with REST APIs or parsing structured data from external sources.
  • 100flutter-use-http-package
    Use the `http` package to execute GET, POST, PUT, or DELETE requests. Use when you need to fetch from or send data to a REST API.
  • 100unirest-java-3
    Unirest-Java 3.x HTTP client library for Java 8+. Use when making HTTP requests (GET/POST/PUT/DELETE), building REST API clients, handling JSON responses, file uploads/downloads, async requests, mocking HTTP calls for testing, configuring proxies, or caching responses. Covers…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.