Upgrade from 1.x to 2.x
BestHTTP/2 is a major version upgrade of the Best HTTP (Pro) package. Because folders got renamed and features removed, this upgrade isn't a drop-in replace of the old version. The old /Best HTTP (Pro)/ folder must be deleted before importing the new package.
Other breaking changes are:
General
- [Breaking change] Removed Statistics API. There's no replacement API for connection releated (active/inactive connections, requests in queue, etc.) statistics. Cookie and cache releated ones can be done through the
CookieJar
andHTTPCacheService
classes. - [Breaking change] Changed some BouncyCastle related class' namespace to avoid collision with other plugins and SDKs. Namespaces now starts with
BestHTTP.SecureProtocol.Org.BouncyCastle.
instead of justOrg.BouncyCastle.
. - [Breaking change] Rewrote Abort mechanism. This shouldn't be a breaking change per se, but there might be uncaught bugs.
- [Breaking change] Minumum Unity version is now 2017.3 as it's the first version to support .asmdef files. Otherwise the plugin should still work under previous versions too.
HTTPRequest
- [Breaking change] New easier to use http streaming API through the
OnStreamingData
event. So instead of callingGetStreamedFragments
periodically in the main callback, error handling in the main callback and data processing can be separated:
var request = new HTTPRequest(new Uri("..."), OnRequestFinished);
request.OnStreamingData += OnDataDownloaded;
void OnDataDownloaded(HTTPRequest request, HTTPResponse response, byte[] data, int dataLength)
{
this.ProcessedBytes += dataLength;
SetDataProcessedUI(this.ProcessedBytes, this.DownloadLength);
// TODO: process downloaded data
}
- [Breaking change]
UseStreaming
is an internal property now. When there's a callback specified forOnStreamingData
, the request automatically becomes a streaming request. - [Breaking change] Removed
GetStreamedFragments
function, use the newOnStreamingData
event. - [Breaking change] Renamed
OnProgress
toOnDownloadProgress
- [Breaking change] Removed
DisableRetry
, useMaxRetries
instead:
var request = new HTTPRequest(new Uri("..."), OnRequestFinished);
//request.DisableRetry = true;
request.MaxRetries = 0;
request.Send();
- [Breaking change] Removed
Priority
property - [Breaking change] Removed
TryToMinimizeTCPLatency
property, because of the plugin's own buffering mechanism it became an always on setting. - [Breaking change] Removed HTTPFormUsage.RawJSon support. There's a small example on how a request can be set up to send json with the RawData property.
Websocket
- [Breaking change] Removed OnErrorDesc event
- [Breaking change] OnError event now has a string parameter instead of an Exception
var webSocket = new WebSocket.WebSocket(new Uri(address));
webSocket.OnError += OnError;
void OnError(WebSocket.WebSocket ws, string error)
{
}
SignalR Core
- [Breaking change] Changed up and down streaming API
Documentation about the new and changed streaming API can be found in the SignalR Core topics.