%% Show How Changing Field Value Changes Field Class
% Create two Content-Length fields using the HeaderField class and its subclass, ContentLengthField. Change the value of the Content-Length field in a message, which changes the class of the field, depending on how you create the original header field.
% Create two header files with the same properties. The fields have the same value, but the classes are different.

h1 = matlab.net.http.HeaderField('Content-Length',5);
h2 = matlab.net.http.field.ContentLengthField(5);
compareNames = eq(h1.Name,h2.Name)
compareValues = eq(h1.Value,h2.Value)

%
% Create a request message using the h1 header field and display its class.

r = matlab.net.http.RequestMessage;
r.Header= h1;
h1Class = class(r.Header)

%
% Change the Content-Length header field using the h2 header field. The header field class changes.

r1 = r.changeFields(h2);
h2Class = class(r1.Header)

%
% Change the Content-Length header field using a name-value pair. The header field class does not change.

r1 = r.changeFields('Content-length',5);
class(r1.Header)

% Copyright 2012 The MathWorks, Inc.