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

com.fasterxml.clustermate.client.jdk.JdkHttpGetCallResult Maven / Gradle / Ivy

Go to download

ClusterMate NetworkClient implementation built on default JDK-provided HTTP client (HTTPUrlConnection)

There is a newer version: 0.10.5
Show newest version
package com.fasterxml.clustermate.client.jdk;

import java.net.HttpURLConnection;

import com.fasterxml.clustermate.client.CallFailure;
import com.fasterxml.clustermate.client.call.GetCallResult;

/**
 * Container for results of a single GET call to a server node.
 * Note that at most one of '_fail' and '_result' can be non-null; however,
 * it is possible for both to be null: this occurs in cases where
 * communication to server(s) succeeds, but no content was found
 * (either 404, or deleted content).
 */
public final class JdkHttpGetCallResult extends GetCallResult
{
    protected final HttpURLConnection _connection;

    /*
    /**********************************************************************
    /* Construction, initialization
    /**********************************************************************
     */
    
    public JdkHttpGetCallResult(HttpURLConnection connection,
            int status, T result) {
        super(status, result);
        _connection = connection;
    }

    public JdkHttpGetCallResult(CallFailure fail) {
        super(fail);
        _connection = null;
    }

    public static  JdkHttpGetCallResult notFound() {
        return new JdkHttpGetCallResult(null, 404, null);
    }

    /*
    /**********************************************************************
    /* Accessors
    /**********************************************************************
     */

    @Override
    public String getHeaderValue(String key)
    {
        if (_connection != null) {
            return _connection.getHeaderField(key);
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy