Main Content

setHttpOptions

Set HTTP options for OSLC client

    Description

    example

    setHttpOptions(myClient,opts) assigns the custom HTTP options opts to the OSLC client myClient.

    Examples

    collapse all

    This example shows how to authenticate an OSLC client by using custom HTTP options.

    Create the OSLC client.

    myClient = oslc.Client;

    Set the server URL, service root and catalog path for your service provider.

    setServer(myClient,'http://example.com');
    setServiceRoot(myClient,'rm');
    setCatalogPath(myClient,'oslc/services/catalog');

    Create and enter the user credentials by using the matlab.net.http.Credentials class with a basic matlab.net.http.AuthenticationScheme object.

    creds = matlab.net.http.Credentials('Username','jdoe','Password', ...
    'Password1234','scheme',matlab.net.http.AuthenticationScheme.Basic);
    

    Create custom HTTP options by using the matlab.net.http.HTTPOptions class constructor. Set the Credentials property for the custom HTTP options.

    opts = matlab.net.http.HTTPOptions('Credentials',creds)
    opts = 
    
      HTTPOptions with properties:
    
               MaxRedirects: 20
             ConnectTimeout: 10
                   UseProxy: 1
                   ProxyURI: []
               Authenticate: 1
                Credentials: [1×1 matlab.net.http.Credentials]
         UseProgressMonitor: 0
                SavePayload: 0
            ConvertResponse: 1
             DecodeResponse: 1
         ProgressMonitorFcn: []
        CertificateFilename: "default"
           VerifyServerName: 1
                DataTimeout: Inf
            ResponseTimeout: Inf
           KeepAliveTimeout: Inf

    Specify the custom HTTP options to authenticate the OSLC client myClient.

    setHttpOptions(myClient,opts);

    Input Arguments

    collapse all

    OSLC client, specified as an oslc.Client object.

    Custom HTTP header, specified as a matlab.net.http.HTTPOptions object.

    Tips

    Introduced in R2021a