Panda3D
Public Types | Public Member Functions | Public Attributes | List of all members
DocumentSpec Class Reference

A descriptor that refers to a particular version of a document. More...

Public Types

enum  CacheControl { CC_allow_cache = 0, CC_revalidate = 1, CC_no_cache = 2 }
 
enum  RequestMode { RM_any = 0, RM_equal = 1, RM_newer = 2, RM_equal_or_newer = 3 }
 

Public Member Functions

 __init__ ()
 
 __init__ (const DocumentSpec copy)
 
 __init__ (const URLSpec url)
 
 __init__ (str url)
 
 clearDate ()
 Removes the last-modified date associated with the DocumentSpec, if there is one. More...
 
 clearTag ()
 Removes the identity tag associated with the DocumentSpec, if there is one. More...
 
int compareTo (const DocumentSpec other)
 
DocumentSpec::CacheControl getCacheControl ()
 Returns the request mode of this DocumentSpec. More...
 
const HTTPDate getDate ()
 Returns the last-modified date associated with the DocumentSpec, if there is one. More...
 
DocumentSpec::RequestMode getRequestMode ()
 Returns the request mode of this DocumentSpec. More...
 
const HTTPEntityTag getTag ()
 Returns the identity tag associated with the DocumentSpec, if there is one. More...
 
const URLSpec getUrl ()
 Retrieves the URL of the DocumentSpec. More...
 
bool hasDate ()
 Returns true if a last-modified date is associated with the DocumentSpec. More...
 
bool hasTag ()
 Returns true if an identity tag is associated with the DocumentSpec. More...
 
bool input (Istream in)
 Can be used to read in the DocumentSpec from a stream generated either by output() or write(). More...
 
bool operator != (const DocumentSpec other)
 
bool operator< (const DocumentSpec other)
 
DocumentSpec operator= (const DocumentSpec copy)
 
bool operator== (const DocumentSpec other)
 
 output (Ostream out)
 
 setCacheControl (DocumentSpec::CacheControl cache_control)
 Specifies what kind of cached value is acceptable for this document. More...
 
 setDate (const HTTPDate date)
 Changes the last-modified date associated with the DocumentSpec. More...
 
 setRequestMode (DocumentSpec::RequestMode request_mode)
 Sets the request mode of this DocumentSpec. More...
 
 setTag (const HTTPEntityTag tag)
 Changes the identity tag associated with the DocumentSpec. More...
 
 setUrl (const URLSpec url)
 Changes the URL of the DocumentSpec without modifying its other properties. More...
 
 write (Ostream out, int indent_level)
 

Public Attributes

DocumentSpec::CacheControl cache_control
 Returns the request mode of this DocumentSpec. More...
 
const HTTPDate date
 Returns the last-modified date associated with the DocumentSpec, if there is one. More...
 
DocumentSpec::RequestMode request_mode
 Returns the request mode of this DocumentSpec. More...
 
const HTTPEntityTag tag
 Returns the identity tag associated with the DocumentSpec, if there is one. More...
 
const URLSpec url
 Retrieves the URL of the DocumentSpec. More...
 

Detailed Description

A descriptor that refers to a particular version of a document.

This includes the URL of the document and its identity tag and last-modified dates.

The DocumentSpec may also be used to request a newer document than a particular one if available, for instance to refresh a cached document.

Member Enumeration Documentation

◆ CacheControl

Enumerator
CC_allow_cache 
CC_revalidate 
CC_no_cache 

◆ RequestMode

Enumerator
RM_any 
RM_equal 
RM_newer 
RM_equal_or_newer 

Member Function Documentation

◆ __init__() [1/4]

__init__ ( )

◆ __init__() [2/4]

__init__ ( const DocumentSpec  copy)

◆ __init__() [3/4]

__init__ ( const URLSpec  url)

◆ __init__() [4/4]

__init__ ( str  url)

◆ clearDate()

clearDate ( )

Removes the last-modified date associated with the DocumentSpec, if there is one.

◆ clearTag()

clearTag ( )

Removes the identity tag associated with the DocumentSpec, if there is one.

◆ compareTo()

int compareTo ( const DocumentSpec  other)

◆ getCacheControl()

DocumentSpec::CacheControl getCacheControl ( )

Returns the request mode of this DocumentSpec.

See set_cache_control().

◆ getDate()

const HTTPDate getDate ( )

Returns the last-modified date associated with the DocumentSpec, if there is one.

It is an error to call this if has_date() returns false.

◆ getRequestMode()

DocumentSpec::RequestMode getRequestMode ( )

Returns the request mode of this DocumentSpec.

See set_request_mode().

◆ getTag()

const HTTPEntityTag getTag ( )

Returns the identity tag associated with the DocumentSpec, if there is one.

It is an error to call this if has_tag() returns false.

The identity tag is set by the HTTP server to uniquely refer to a particular version of a document.

◆ getUrl()

const URLSpec getUrl ( )

Retrieves the URL of the DocumentSpec.

◆ hasDate()

bool hasDate ( )

Returns true if a last-modified date is associated with the DocumentSpec.

◆ hasTag()

bool hasTag ( )

Returns true if an identity tag is associated with the DocumentSpec.

◆ input()

bool input ( Istream  in)

Can be used to read in the DocumentSpec from a stream generated either by output() or write().

Returns true on success, false on failure.

◆ operator !=()

bool operator != ( const DocumentSpec  other)

◆ operator<()

bool operator< ( const DocumentSpec  other)

◆ operator=()

DocumentSpec operator= ( const DocumentSpec  copy)

◆ operator==()

bool operator== ( const DocumentSpec  other)

◆ output()

output ( Ostream  out)

◆ setCacheControl()

setCacheControl ( DocumentSpec::CacheControl  cache_control)

Specifies what kind of cached value is acceptable for this document.

Warning: some HTTP proxies may not respect this setting and may return a cached result anyway.

CC_allow_cache: the normal HTTP behavior; the server may return a cached value if it believes it is valid.

CC_revalidate: a proxy is forced to contact the origin server and verify that is cached value is in fact still valid before it returns it.

CC_no_cache: a proxy must not return its cached value at all, but is forced to go all the way back to the origin server for the official document.

The default mode is CC_allow_cache.

◆ setDate()

setDate ( const HTTPDate  date)

Changes the last-modified date associated with the DocumentSpec.

◆ setRequestMode()

setRequestMode ( DocumentSpec::RequestMode  request_mode)

Sets the request mode of this DocumentSpec.

This is only relevant when using the DocumentSpec to generate a request (for instance, in HTTPChannel). This specifies whether the document request will ask the server for a newer version than the indicated version, or the exact version, neither, or either.

The possible values are:

RM_any: ignore date and tag (if specified), and retrieve any document that matches the URL. For a subrange request, if the document matches the version indicated exactly, retrieve the subrange only; otherwise, retrieve the entire document.

RM_equal: request only the precise version of the document that matches the particular date and/or tag exactly, if specified; fail if this version is not available.

RM_newer: request any document that is newer than the version indicated by the particular date and/or tag; fail if only that version (or older versions) are available.

RM_newer_or_equal: request any document that matches the version indicated by the particular date and/or tag, or is a newer version; fail if only older versions are available.

In any of the above, you may specify either or both of the last-modified date and the identity tag, whichever is known to the client.

The default mode is RM_any.

◆ setTag()

setTag ( const HTTPEntityTag  tag)

Changes the identity tag associated with the DocumentSpec.

◆ setUrl()

setUrl ( const URLSpec  url)

Changes the URL of the DocumentSpec without modifying its other properties.

Normally this would be a strange thing to do, because the tag and date are usually strongly associated with the URL. To get a DocumentSpec pointing to a new URL, you would normally create a new DocumentSpec object.

◆ write()

write ( Ostream  out,
int  indent_level 
)

Member Data Documentation

◆ cache_control

Returns the request mode of this DocumentSpec.

See set_cache_control().

◆ date

const HTTPDate date

Returns the last-modified date associated with the DocumentSpec, if there is one.

It is an error to call this if has_date() returns false.

◆ request_mode

Returns the request mode of this DocumentSpec.

See set_request_mode().

◆ tag

const HTTPEntityTag tag

Returns the identity tag associated with the DocumentSpec, if there is one.

It is an error to call this if has_tag() returns false.

The identity tag is set by the HTTP server to uniquely refer to a particular version of a document.

◆ url

const URLSpec url

Retrieves the URL of the DocumentSpec.