Best HTTP

About Best HTTP – Unity Editor Tool & Plugin

Best HTTP Unity Asset Overview

networking has consistently been one of those domains where simple solutions work great in prototyping, but completely fall apart once you hit production across multiple platforms. Unity's native UnityWebRequest is fine for fetching a basic texture or a light JSON payload on standalone builds. However, the moment you need high-throughput streaming, resilient connection pooling, native HTTP/2 support, WebSockets, or SignalR integration that behaves identically across iOS, Android, Desktop, and WebGL—things get messy.

That is where Best HTTP comes into the picture. Built by Benedek Habzda (TRF Games), it is a comprehensive network stack written completely in C# that replaces or augments Unity's underlying network transport. Rather than relying on OS-level wrappers that behave differently between target platforms, Best HTTP provides a unified engine for handling REST APIs, binary data streaming, and real-time socket connections. The core architecture is built from the ground up to minimize heap allocations, optimize socket re-use via intelligent HTTP/1.1 and HTTP/2 connection pools, and handle modern TLS/SSL configurations smoothly.

Core Technical Features & Highlights

1. Protocol Support & Socket Abstractions

Best HTTP covers virtually every web standard required by modern backend architectures:

2. Memory Optimization & Buffer Recycling

Honestly, the single biggest headache with networking in Unity is the Garbage Collector (GC). Receiving large assets or continuous WebSocket streams can easily choke your frame rate if memory is allocated dynamically on every packet. Best HTTP addresses this by integrating a dedicated internal BufferPool system. Incoming network data is written directly into reused byte arrays, significantly reducing allocations during heavy networking loops.

3. Cross-Platform Engine & Security

Networking bugs that only manifest on WebGL or iOS are notoriously hard to debug. Best HTTP solves this by executing pure C# sockets on platforms that support them, while offering a specialized WebGL fallback wrapper that leverages browser APIs when native sockets are restricted. Security-wise, it includes support for custom TLS/SSL validation, client certificates, and SNI (Server Name Indication), making HTTPS pinning straightforward.

Ideal Use Cases & Game Genres

While Best HTTP can handle basic HTTP requests, its architecture shines brightest in data-intensive and real-time multiplayer applications:

Quick-Start Unity Setup & Integration Guide

Setting up Best HTTP in a project is straightforward. Once imported into your asset directory, you do not need complex scene setups; requests can be dispatched directly from scripts or encapsulated within singletons.

Basic POST Request Example

Here is how you can issue a JSON POST request with custom headers, set timeouts, and handle the response without blocking the main Unity thread:

using System;
using UnityEngine;
using BestHTTP;

public class BackendServices : MonoBehaviour
{
    public void SubmitPlayerScore(string playerId, int score)
    {
        string endpoint = "https://api.mygame.com/v1/leaderboard";
        string jsonPayload = $"{{\"playerId\":\"{playerId}\",\"score\":{score}}}";

        var request = new HTTPRequest(new Uri(endpoint), HTTPMethods.Post, OnScoreSubmitted);
        
        request.SetHeader("Content-Type", "application/json");
        request.SetHeader("Authorization", "Bearer YOUR_JWT_TOKEN_HERE");
        request.RawData = System.Text.Encoding.UTF8.GetBytes(jsonPayload);
        
        // Configure timeouts and retry policies
        request.Timeout = TimeSpan.FromSeconds(10);
        request.ConnectTimeout = TimeSpan.FromSeconds(5);

        request.Send();
    }

    private void OnScoreSubmitted(HTTPRequest req, HTTPResponse resp)
    {
        if (resp == null)
        {
            Debug.LogError("Network Error: Server was unreachable or request timed out.");
            return;
        }

        if (resp.IsSuccess)
        {
            Debug.Log($"Score submitted successfully! Server response: {resp.DataAsText}");
        }
        else
        {
            Debug.LogWarning($"Request failed with status code: {resp.StatusCode} - {resp.Message}");
        }
    }
}

Key Integration Advice:

Always register global setup configurations in an early initialization script (e.g., inside Awake or a RuntimeInitializeOnLoadMethod). You can configure global connection limits, caching rules, and HTTP/2 settings globally through the HTTPManager class:

using BestHTTP;
using UnityEngine;

public class NetworkInitializer : MonoBehaviour
{
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    private static void InitNetworkSettings()
    {
        HTTPManager.MaxConnectionPerServer = 6;
        HTTPManager.KeepAliveDefault = true;
        HTTPManager.IsCachingDisabled = false;
    }
}

Pros & Cons Assessment

Pros

Cons

Frequently Asked Questions (FAQ)

1. Is Best HTTP significantly better than UnityWebRequest for simple mobile games?

If your game only makes two API calls per session to fetch a score, UnityWebRequest is sufficient. However, if your mobile game handles background downloads, unstable connection switches (e.g., 4G to Wi-Fi mid-game), WebSockets, or high-frequency telemetry, Best HTTP is much more reliable and handles retry logic and connection pooling automatically.

2. Can Best HTTP handle WebGL cross-origin (CORS) restrictions?

Best HTTP respects standard browser security rules when running inside WebGL builds because it routes requests through the browser's native networking stack. However, it manages header injection, cookies, and callback handling gracefully, saving you from writing custom JavaScript wrappers.

3. What is the licensing policy regarding this package?

Please note that any assets provided or downloaded on this platform are intended strictly for educational, testing, and evaluation purposes only. They must never be used in commercial production releases. If you intend to ship a game or application commercially using Best HTTP, please purchase an official license directly from the Unity Asset Store to support the developer and receive official updates and support.

Technical Specifications

  • Category: Tools
  • Sub-Category: Network
  • Latest Version: 3.1.0
  • File Size: 2.52 MB

Related Unity Tools Assets