Web request low-level API reference
Perform more advanced HTTP operations with the low-level web request APIs.
Read time 4 minutesLast updated 6 days ago
While the high-level web request API minimizes the need for boilerplate code, the low-level web request API offers more flexibility and control.
This section lists key members of the low-level API and the scenarios they're intended for. In general, using the low-level API involves creating a to which you attach specialized or objects for particular download and upload cases.
UnityWebRequestDownloadHandlerUploadHandlerThe high and low-level APIs aren't mutually exclusive. You can always customize objects created via the high-level API if you need more control over a common operation.
UnityWebRequestInstantiating UnityWebRequest objects
UnityWebRequestUnityWebRequestUnityWebRequestFor more information, refer to the API reference.
UnityWebRequestDownload handlers
Specialist download handlers allow you to handle specific download cases and control the processing of incoming data. The following download handlers are available, which all specialize the base class:
DownloadHandlerHandler type | Description |
|---|---|
| Used for simple data storage. This download handler is the simplest, and handles the majority of use cases. It stores received data in a native code buffer. When the download is complete, you can access the buffered data either as an array of bytes or as a text string. |
| Specialized download handler for downloading and saving large files to disk with low memory footprint. It writes downloaded bytes directly to file, so the memory usage is low regardless of the size of the file being downloaded. The difference from other download handlers is that you retrieve data from the saved file rather than from the handler itself. |
| Specialized download handler optimized for downloading images for use as Unity Texture objects. This is a more efficient alternative to using a |
| Specialized download handler optimized for downloading Unity AssetBundles. It can stream data directly to Unity's asset system and produce an |
| Specialized download handler optimized for downloading audio files. This is a more efficient alternative to downloading raw bytes using |
| An abstract base class for custom, scriptable |
UnityWebRequestUnityWebRequest.disposeDownloadHandlerOnDisposeUnityWebRequest.DisposeDownloadHandler.DisposeUnityWebRequestdisposeDownloadHandlerOnDisposeUpload handlers
Upload handlers allow you more detailed control of aspects of the upload process. The following upload handlers are available, which all specialize the base class:
UploadHandlerHandler type | Description |
|---|---|
| Accepts a data buffer at construction time. When this buffer is an array of bytes, it's copied internally into native code memory. |
| Allows you to send the contents of a file as the request body. Using this handler, you can send a large file to a server without using a lot of memory. Because the handler continually reads data from the file and then sends it, only a small fraction of the file is kept in memory at any given time. |
The value of the property is used for the value of the web request's header if you don't set one directly on the itself. If you do set a header on the object, the on the upload handler object is ignored. If you don't set a on either the or the , the system defaults to setting a of .
UploadHandler.contentTypeContent-TypeUnityWebRequestContent-TypeUnityWebRequestContent-TypeContent-TypeUnityWebRequestUploadHandlerContent-Typeapplication/octet-streamUnityWebRequestdisposeUploadHandlerOnDisposeUnityWebRequest.DisposeUploadHandler.DisposeUnityWebRequestdisposeUploadHandlerOnDispose