Documentation

matlab.net.http.field.GenericField class

Package:matlab.net.http.field
Superclasses:matlab.net.http.HeaderField

HTTP报头字段with any name and value

Description

Use aGenericFieldheader field for testing or to work around a built-in restriction that might not be appropriate for your application. TheHeaderFieldclass and its subclasses validate theValueproperty for the givenNameproperty. To override aValuethat might otherwise be rejected, create aGenericFieldheader field.

If a header field in a response message contains a value that is not valid for the field name, MATLAB®creates aGenericFieldobject.

Construction

example

obj = matlab.net.http.field.GenericField(name,value)creates an HTTP header field with theNameproperty set tonameand theValueproperty set tovalue.

Properties

expand all

Header field name, specified as a string or character vector.

Header value, specified as a string or character vector.

Methods

convert

Valueof header field as MATLAB type.

MATLAB checks thematlab.net.http.fieldpackage for a class with theGenericField.Nameproperty. If there is a class for this field, thenconvertinvokes theconvertmethod of that class.

If the conversion fails or if no class supports thisNameproperty, thenconvertthrows an exception.

Attributes

Sealed true

Examples

expand all

A Content-Length header field must contain a number.

The following statement generates an error.

field = matlab.net.http.field.ContentLengthField('abc');

If instead you need a character value, create aGenericFieldobject.

field = matlab.net.http.field.GenericField('Content-Length','abc');

Introduced in R2016b

Was this topic helpful?