Appendix: Headers#

To specify headers on all client requests, you can set the headers for the SolidClient/SolidSyncClient. To read the response headers, you can use the getHeaders() method for the resource:

For example:

import com.inrupt.client.Headers;
import com.inrupt.client.solid.SolidClient;

// ...
// ...

final SolidClient mySolidClient = SolidClient.getClientBuilder()
                .headers(Headers.of(Map.of("x-request-id", List.of("7492595229158059")))).build()
                .session(session);

client.read(URI.create(resourceURL), MyExtendedRDF.class)
    .thenAccept(responseResource -> {
       List<String> responseHeaderValues = responseResource.getHeaders().allValues("x-request-id");
       // ...
});

To specify headers per request, you can set the headers at the request operation level. To read the response headers, you can use the getHeaders() method for the resource:

For example:

import com.inrupt.client.Headers;
import com.inrupt.client.solid.SolidClient;

// ...
// ...

final SolidClient mySolidClient = SolidClient.getClient().session(session);

Headers myHeaders = Headers.of(Map.of("x-request-id", List.of("7492595229158059")));

mySolidClient.read(URI.create(resourceURL), myHeaders, Expense.class)
   .thenAccept(responseExpense -> {
       List<String> responseHeaderValues = responseExpense.getHeaders().allValues("x-request-id");
       // ...
});

See:

Additional Information#

Alternatively, you can also use the resource class’ getMetadata() methods:

The getMetadata() methods return Solid-specific data (parsed into Java types) from a resource’s response headers. To access the complete set of response headers, use the getHeaders() methods.