matlab.net.http.field.AuthenticateField - HTTP WWW-Authenticate or Proxy-Authenticate header field - MATLAB (original) (raw)
Namespace: matlab.net.http.field
Superclasses: matlab.net.http.HeaderField
HTTP WWW-Authenticate or Proxy-Authenticate header field
Description
An AuthenticateField
object contains one or more challenges from a server asking for authentication information. A server or proxy creates anAuthenticateField
in a response message.
When you send a request message to a server or through a proxy that requires authentication, MATLABĀ® automatically tries to authenticate to the server or proxy when:
HTTPOptions.Authenticate
property is true (default)HTTPOptions.Credentials
property contains the necessary names and passwords.
If authentication is successful, then the response message returns anOK
status and does not contain an authentication field.
If you disable authentication or if authentication failed, then the response message returns an authentication field. In that case, the status code of the response message is either 401 (Unauthorized
) or 407 (ProxyAuthenticationRequired
). Examine the AuthInfo
object and respond by adding the appropriate AuthorizationField
to the request message containing your credentials. Or resend the request by setting the correctCredentials
property in HTTPOptions
.
If the server or proxy requires an authentication scheme that MATLAB does not support, you must implement the authentication protocol yourself. Create a request message with the appropriate credentials and other information.
Creation
Description
obj = matlab.net.http.field.AuthenticateField(name,value)
creates an authentication header field with the Name property set toname
and the Value property set tovalue
.
A server creates this field in a response message. Use this constructor for test purposes.
Properties
Header field name, specified as 'WWW-Authenticate'
or'Proxy-Authenticate'
.
Attributes:
GetAccess | public |
---|---|
SetAccess | public |
A comma-separated list of challenges, specified as a vector of matlab.net.http.AuthInfo objects or a string in the format defined by RFC 7235 Hypertext Transfer Protocol (HTTP/1.1): Authentication and RFC 2617 HTTP Authentication: Basic and Digest Access Authentication on the RFC Editor website. Use the AuthenticateField.convert
method to parse this field.
Attributes:
GetAccess | public |
---|---|
SetAccess | public |
Dependent | true |
Methods
addFields | Add fields to HeaderField array |
---|---|
removeFields | Remove fields from header field array |
changeFields | Change existing values in HeaderField array |
replaceFields | Change values in or add fields to array of HeaderFields |
getFields | Return header fields matching name or class |
eq | Compare two HeaderField arrays |
convertLike | Convert header field value like another header field |
parse | Parse header field value and return as strings |
displaySubclasses | Display supported HeaderField subclasses |
convert | Value property of AuthenticateField as vector of AuthInfo objects, one for each challenge in the header field, in the order they appear inAuthenticateField. |
---|
These methods specialize standard MATLAB operators and functions for objects in this class.
isequal | true if two header field arrays are the same size and corresponding elements are equal, as described by eq method |
---|---|
string | Array of header fields as string, as it appears in a message. Inserts newline characters between fields but not at the end of all fields. |
char | Array of header fields as character vector, as described bystring method |
Examples
This example shows how to set the authentication scheme in a request message.
Specify Image URL
import matlab.net.; import matlab.net.http.;
httpsUrl = "https://requestserver.mathworks.com"; uri = URI(strcat(httpsUrl, "/assets/computerVision.jpg?authenticate=digest"));
Set Credentials
Set the authentication scheme to Digest
and provide login credentials.
cred = Credentials("Scheme", "Digest", "Username", "testName", "Password", "testPass"); options = HTTPOptions; options.Credentials = cred; options.Authenticate = false; req = RequestMessage('GET'); response = req.send(uri, options); authenticateField = response.getFields("WWW-Authenticate"); disp(authenticateField)
AuthenticateField with properties:
Name: "WWW-Authenticate"
Value: "Digest realm="Digest Authentication",qop="auth",nonce="0.3598425461739989",opaque="0d3ced1a5756977875a15f93cc12dd21""
Version History
Introduced in R2016b