Symbian
 Developer Library

DEVELOPER LIBRARY

[Index] [Glossary] [Previous] [Next]



Location: http\rhttpheaders.h
Link against: http.lib

Class RHTTPHeaders

class RHTTPHeaders

Support

Supported from 7.0

Description

A collection of header fields associated with a message.

Header fields can be created, read and modified. They may be composed of several parts (by repeated invocations of API methods, see below) and may be assigned one or more parameters. Individual field parts and parameters take values described using THTTPHdrVal.

Defined in RHTTPHeaders:
FieldPartsL(), Fields(), GetField(), GetParam(), GetRawField(), RHTTPHeaders(), RemoveAllFields(), RemoveField(), RemoveFieldPart(), SetFieldL(), SetFieldL(), SetParamL(), SetRawFieldL(), iImplementation

See also:


Construction and destruction


RHTTPHeaders()

inline RHTTPHeaders();

Description

Default constructor.

[Top]


Member Functions


FieldPartsL()

TInt FieldPartsL(RStringF aFieldName) const;

Description

Gets the number of parts in the named header field's value.

Simple headers are created with a single part following one call to SetFieldL(). Subsequent calls to SetFieldL() create additional parts if the field exists already.

Parameters

RStringF aFieldName

Field name

Return value

TInt

Number of parts


GetField()

TInt GetField(RStringF aFieldName, TInt aPartIdx, THTTPHdrVal& aHeaderValue) const;

Description

Gets the named header field's value.

The index of a part within the field must be specified. Parts are indexed from 0. Fields with only one part return the entire field for index 0.

Parameters

RStringF aFieldName

Field name

TInt aPartIdx

The index of the part

THTTPHdrVal& aHeaderValue

On return, the header field value

Return value

TInt

An error condition. Returns KErrNotFound if there is not a field with the specifed field name.


GetRawField()

TInt GetRawField(RStringF aFieldName, TPtrC8& aRawFieldData) const;

Description

Gets a raw representation of the named header field's value.

Note that client use of this method is strongly discouraged since it exposes the raw representation of particular headers. However, it may be needed for some cases where received headers could not be decoded by HTTP. It is normally used internally when preparing header data to be transmitted with a request.

Parameters

RStringF aFieldName

The field name, e.g, 'Content-Type'

TPtrC8& aRawFieldData

The field's data content, in an appropriate raw form

Return value

TInt

An error condition. Returns KErrNotFound if there is not a field with the specifed field name.


GetParam()

TInt GetParam(RStringF aFieldName, RStringF aParamName, THTTPHdrVal& aReturn, TInt aPartIdx=0) const;

Description

Gets the value of a named parameter, associated with the named header field.

Parameters

RStringF aFieldName

The header name

RStringF aParamName

The parameter name

THTTPHdrVal& aReturn

The returned value. Note that this must be Copy()d by the caller, if it wants to keep the value.

TInt aPartIdx=0

The index of the part. By default, the first part.

Return value

TInt

An error condition. Returns KErrNotFound if there is not a field with the specifed field name.


Fields()

THTTPHdrFieldIter Fields() const;

Description

Gets an iterator for the header fields.

Each application of the iterator returns the name of the next field type. This may then be accessed through GetField().

Return value

THTTPHdrFieldIter

The iterator.


SetFieldL()

void SetFieldL(RStringF aFieldName, THTTPHdrVal aFieldValue);

Description

Sets a named field in the header.

On the first instance that this API method is used for a given field name, the field will be created. On subsequent calls, the same field will be extended to have several parts, with a new part created to hold the supplied value.

Parameters

RStringF aFieldName

Field name

THTTPHdrVal aFieldValue

Field value


SetFieldL()

void SetFieldL(RStringF aFieldName, THTTPHdrVal aFieldValue, RStringF aParamName, THTTPHdrVal aParamValue);

Description

Sets a named field in the header, and associates the supplied parameter with it.

If the field doesn't already exist, it will be created with a parameter; if it does exist, then a new part will be created with the parameter.

Parameters

RStringF aFieldName

The field name, e.g. 'Accept'

THTTPHdrVal aFieldValue

The field value. e.g. 'text/plain'

RStringF aParamName

The parameter name, e.g. 'q'

THTTPHdrVal aParamValue

The parameter value, e.g. '0.3'


SetParamL()

void SetParamL(RStringF aFieldName, RStringF aParamName, THTTPHdrVal aParamValue, TInt aPartIdx);

Description

Set a parameter in an existing field.

Parameters

RStringF aFieldName

The field name, e.g. 'Accept'

RStringF aParamName

The parameter name, e.g. 'q'

THTTPHdrVal aParamValue

The parameter value, e.g. '0.3'

TInt aPartIdx

The part of the header to add the parameter to

Leave codes

KErrNotFound

Field does not exist


SetRawFieldL()

void SetRawFieldL(RStringF aFieldName, const TDesC8& aRawFieldData);

Description

Set a named field in the header to contain the supplied raw header data.

If the header already exists then a LF and the new data will be added to the existing data. This is used to indicate that there are multiple instances of this header.

Note that general client use of this method is strongly discouraged since it exposes the raw representation of particular headers. However it may be needed for some cases where HTTP could not locate an encoder that could handle the header. It is normally used internally when encoding request headers supplied by a client.

Parameters

RStringF aFieldName

The field name, e.g, 'Content-Type'

const TDesC8& aRawFieldData

The field's data content, in a raw form


RemoveField()

TInt RemoveField(RStringF aFieldName);

Description

Removes, entirely, the named header field from the header collection.

All its parts and associated parameters, where they exist, are also removed.

Parameters

RStringF aFieldName

The field name.

Return value

TInt

KErrNone if the removal is successful; KErrNotFound if the field didn't exist within the headers.


RemoveFieldPart()

TInt RemoveFieldPart(RStringF aFieldName, TInt aIndex);

Description

Removes a single part of a header field.

Only the part and any associated parameters are removed. If this results in no parts being present in the header field, then it will also be removed

Parameters

RStringF aFieldName

The header name

TInt aIndex

The part of the field to be removed

Return value

TInt

KErrNone if the removal is successful; KErrNotFound if the header didn't exist. No exception is raised if the particular value is not found as part of that header


RemoveAllFields()

void RemoveAllFields();

Description

Removes all the fields of this header collection.

[Top]


Internal members


iImplementation

private: CHeaders* iImplementation;

Description

This is internal and not intended for use.