SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWHttpContentTypeHeader Class Reference

Helper class that defines an HTTP Content-Type header. More...

#include <rw/http/RWHttpContentTypeHeader.h>

Inheritance diagram for RWHttpContentTypeHeader:
RWHttpHeaderBase

Public Member Functions

 RWHttpContentTypeHeader (const RWCString &mediaType, const RWCString &subType)
 
 RWHttpContentTypeHeader (const RWHttpGenericHeader &hdr)
 
 RWHttpContentTypeHeader (void)
 
bool addParameter (const RWCString &name, const RWCString &value)
 
RWCString getMediaType (void) const
 
RWTValSlist< RWCStringgetParameterNames (void) const
 
RWCString getParameterValue (const RWCString &name) const
 
RWCString getSubType (void) const
 
RWCString getValue (void) const
 
bool removeParameter (const RWCString &name)
 
void setContentType (const RWCString &mediaType, const RWCString &subType)
 
- Public Member Functions inherited from RWHttpHeaderBase
virtual bool append (const RWCString &str)
 
virtual RWCString asString (void) const
 
RWCString getLabel (void) const
 
RWHttpHeaderType getType (void) const
 
bool operator!= (const RWHttpHeaderBase &) const
 
bool operator< (const RWHttpHeaderBase &hdr) const
 
bool operator== (const RWHttpHeaderBase &h) const
 

Additional Inherited Members

- Static Public Member Functions inherited from RWHttpHeaderBase
static unsigned hash (const RWHttpHeaderBase &)
 
- Protected Member Functions inherited from RWHttpHeaderBase
 RWHttpHeaderBase (const RWCString &label, RWHttpHeaderType type=RW_HTTP_ENTITY_HEADER)
 
 RWHttpHeaderBase (void)
 

Detailed Description

RWHttpContentTypeHeader is a specialization class of RWHttpHeaderBase. It is a helper class that formats its contents as Content-Type: header_value, where header_value is the media type and sub type of the message, as well as any parameters describing the content.

Example
RWHttpContentTypeHeader hdr("text", "plain");
hdr.addParameter("charset", "iso-2022-jp");
Helper class that defines an HTTP Content-Type header.
Definition RWHttpContentTypeHeader.h:41

Constructor & Destructor Documentation

◆ RWHttpContentTypeHeader() [1/3]

RWHttpContentTypeHeader::RWHttpContentTypeHeader ( void )
inline

Constructs a default RWHttpContentTypeHeader object with the label Content-Type and the value text/plain.

◆ RWHttpContentTypeHeader() [2/3]

RWHttpContentTypeHeader::RWHttpContentTypeHeader ( const RWCString & mediaType,
const RWCString & subType )

Constructs an RWHttpContentTypeHeader with the label Content-Type and the value mediaType / subType.

◆ RWHttpContentTypeHeader() [3/3]

RWHttpContentTypeHeader::RWHttpContentTypeHeader ( const RWHttpGenericHeader & hdr)

Constructs an RWHttpContentTypeHeader object from an RWHttpGenericHeader that represents a Content-Type header. If the RWHttpGenericHeader does not represent a Content-Type header or if the value of the RWHttpGenericHeader does not conform to the formatting of a Content-Type value, an RWHttpHeaderParseError exception is thrown.

Member Function Documentation

◆ addParameter()

bool RWHttpContentTypeHeader::addParameter ( const RWCString & name,
const RWCString & value )

Add a parameter to this header. If the parameter is not currently associated with this instance, the parameter will be added, and true will be returned, false otherwise.

◆ getMediaType()

RWCString RWHttpContentTypeHeader::getMediaType ( void ) const

Returns the media type of this instance.

◆ getParameterNames()

RWTValSlist< RWCString > RWHttpContentTypeHeader::getParameterNames ( void ) const

Returns a list of parameter names associated with this instance. The values associated with these parameter names can be retrieved with the getParameterValue() method.

◆ getParameterValue()

RWCString RWHttpContentTypeHeader::getParameterValue ( const RWCString & name) const

Returns the value associated with a parameter associated with this instance. If the name does not match a parameter in the list, an empty string is returned.

◆ getSubType()

RWCString RWHttpContentTypeHeader::getSubType ( void ) const

Returns the sub type of this instance.

◆ getValue()

RWCString RWHttpContentTypeHeader::getValue ( void ) const
virtual

Returns the value of this header as an RWCString. This includes the media and sub types, as well as any parameters associated with the header, formatted according the HTTP specification's requirements.

Implements RWHttpHeaderBase.

◆ removeParameter()

bool RWHttpContentTypeHeader::removeParameter ( const RWCString & name)

Removes the parameter associated with name from the parameter list. If the parameter is not present, false is returned.

◆ setContentType()

void RWHttpContentTypeHeader::setContentType ( const RWCString & mediaType,
const RWCString & subType )

Sets the mediaType and subType of this instance.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.