All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.oracle.bmc.http.client.HttpResponse Maven / Gradle / Ivy

Go to download

This project contains the SDK distribution used for Oracle Cloud Infrastructure, and all the dependencies that can be shaded. It also has Maven dependencies that cannot be shaded. Therefore, use this module to depend on the shaded distribution via Maven -- it will shade everything that can be shaded, and automatically pull in the other dependencies.

There is a newer version: 3.50.0
Show newest version
/**
 * Copyright (c) 2016, 2024, Oracle and/or its affiliates.  All rights reserved.
 * This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
 */
package com.oracle.bmc.http.client;

import java.io.Closeable;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletionStage;

public interface HttpResponse extends Closeable {
    int status();

    Map> headers();

    default String header(String name) {
        List candidates = headers().get(name);
        if (candidates != null && !candidates.isEmpty()) {
            return candidates.get(0);
        } else {
            return null;
        }
    }

    CompletionStage streamBody();

     CompletionStage body(Class type);

     CompletionStage> listBody(Class type);

    CompletionStage textBody();

    /**
     * Close this response. Some operations on the request will not work after this call (notably
     * {@link #body(Class)}). However if the body has already been requested, that body will remain
     * valid even if the stage has not yet completed, or if it is a streaming response ({@link
     * java.io.InputStream}). Such a response needs to be closed separately.
     */
    // todo: some way to cancel the request for the parsed body if the CompletionStage has not
    // returned yet?
    @Override
    void close();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy