CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::IURLResponse Class Referenceabstract

The metadata associated with the response to a URL load request, independent of protocol and URL scheme. More...

#include <CeresEngine/Foundation/IO/URLSession.hpp>

Inheritance diagram for CeresEngine::IURLResponse:
CeresEngine::FileURLProtocol::Response

Public Member Functions

 IURLResponse (URLRequest request)
 Creates a new URLResponse from a request.
 
virtual ~IURLResponse () noexcept=default
 Destroys the URLResponse.
 
virtual URLInputStream openInputStream ()=0
 Opens a new stream that can receive the data from the response.
 
virtual URLOutputStream openOutputStream ()
 Opens a new stream that can write the data from the response.
 
virtual URLDataStream openDataStream ()
 Opens a new stream that can read and write the data from the response.
 
JSON asJSON ()
 Opens the stream and reads it as a JSON file.
 

Public Attributes

const URLRequest request
 The request that triggered the response.
 
UInt64 expectedContentLength = ~0ul
 The expected length of the response's content.
 
String suggestedFileName = ""
 A suggested filename for the response data.
 
String mimeType = ""
 The MIME type of the response.
 
String textEncodingName = ""
 The name of the text encoding provided by the response's originating source.
 
UUID contentID
 A ID that uniquely represents a content.
 

Detailed Description

The metadata associated with the response to a URL load request, independent of protocol and URL scheme.

URLResponse objects don't contain the actual bytes representing the content of a URL. Instead, the data is returned using DataStreams that can be fetched from the URLResponse.

Constructor & Destructor Documentation

◆ IURLResponse()

CeresEngine::IURLResponse::IURLResponse ( URLRequest  request)
inlineexplicit

Creates a new URLResponse from a request.

Parameters
requestThe request the response corresponds to.

◆ ~IURLResponse()

virtual CeresEngine::IURLResponse::~IURLResponse ( )
virtualdefaultnoexcept

Destroys the URLResponse.

Member Function Documentation

◆ asJSON()

JSON CeresEngine::IURLResponse::asJSON ( )

Opens the stream and reads it as a JSON file.

◆ openDataStream()

virtual URLDataStream CeresEngine::IURLResponse::openDataStream ( )
inlinevirtual

Opens a new stream that can read and write the data from the response.

Not that not all protocols allow reading and writing data to the response.

Reimplemented in CeresEngine::FileURLProtocol::Response.

◆ openInputStream()

virtual URLInputStream CeresEngine::IURLResponse::openInputStream ( )
pure virtual

Opens a new stream that can receive the data from the response.

Not that not all protocols allow calling this more than once.

Implemented in CeresEngine::FileURLProtocol::Response.

◆ openOutputStream()

virtual URLOutputStream CeresEngine::IURLResponse::openOutputStream ( )
inlinevirtual

Opens a new stream that can write the data from the response.

Not that not all protocols allow writing data to the response.

Reimplemented in CeresEngine::FileURLProtocol::Response.

Member Data Documentation

◆ contentID

UUID CeresEngine::IURLResponse::contentID

A ID that uniquely represents a content.

The content ID allows some protocols to implement improved caching, as well as reuse expensive operations between multiple requests that reference the same content ID. For example, a ZIP protocol can use the content ID to uniquely identify a ZIP file and thus allow to open the ZIP file just once and re-use the same handle for multiple requests.

◆ expectedContentLength

UInt64 CeresEngine::IURLResponse::expectedContentLength = ~0ul

The expected length of the response's content.

This property's value is NSURLResponseUnknownLength if the length can't be determined.

Some protocol implementations report the content length as part of the response, but not all protocols guarantee to deliver that amount of data. Your app should be prepared to deal with more or less data.

◆ mimeType

String CeresEngine::IURLResponse::mimeType = ""

The MIME type of the response.

The MIME type is often provided by the response's originating source. However, that value may be changed or corrected by a protocol implementation if it can be determined that the response's source reported the information incorrectly.

If the response's originating source does not provide a MIME type, an attempt to guess the MIME type may be made.

◆ request

const URLRequest CeresEngine::IURLResponse::request

The request that triggered the response.

◆ suggestedFileName

String CeresEngine::IURLResponse::suggestedFileName = ""

A suggested filename for the response data.

Accessing this property attempts to generate a filename using the following information, in order:

  • A filename specified using the content disposition header.
  • The last path component of the URL.
  • The host of the URL.

If the host of URL can't be converted to a valid filename, the filename “unknown” is used. In most cases, this property appends the proper file extension based on the MIME type. Accessing this property always returns a valid filename regardless of whether the resource is saved to disk.

◆ textEncodingName

String CeresEngine::IURLResponse::textEncodingName = ""

The name of the text encoding provided by the response's originating source.

If no text encoding was provided by the protocol, this property's value is empty.


The documentation for this class was generated from the following file: