Package org.yamcs.client
Class HttpClient
- java.lang.Object
-
- org.yamcs.client.HttpClient
-
public class HttpClient extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
MT_JSON
static String
MT_PROTOBUF
-
Constructor Summary
Constructors Constructor Description HttpClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCookie(io.netty.handler.codec.http.cookie.Cookie c)
void
close()
CompletableFuture<byte[]>
doAsyncRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, byte[] body)
CompletableFuture<byte[]>
doAsyncRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, byte[] body, io.netty.handler.codec.http.HttpHeaders extraHeaders)
CompletableFuture<Void>
doBulkReceiveRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, byte[] body, BulkRestDataReceiver receiver)
Perform a request that potentially retrieves large amount of data.CompletableFuture<Void>
doBulkRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, String body, BulkRestDataReceiver receiver)
CompletableFuture<BulkRestDataSender>
doBulkSendRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod)
String
getAcceptMediaType()
List<io.netty.handler.codec.http.cookie.Cookie>
getCookies()
Credentials
getCredentials()
String
getSendMediaType()
boolean
isInsecureTls()
void
login(String tokenUrl, String username, char[] password)
void
loginWithAuthorizationCode(String tokenUrl, String authorizationCode)
void
refreshAccessToken()
void
setAcceptMediaType(String acceptMediaType)
void
setCaCertFile(String caCertFile)
In case of https connections, this file contains the CA certificates that are used to verify server certificatevoid
setInsecureTls(boolean insecureTls)
if true and https connections are used, do not verify server certificatevoid
setMaxResponseLength(int length)
Sets the maximum size of the responses - this is not applicable to bulk requests whose response is practically unlimited and delivered piece by piecevoid
setSendMediaType(String sendMediaType)
-
-
-
Field Detail
-
MT_JSON
public static final String MT_JSON
- See Also:
- Constant Field Values
-
MT_PROTOBUF
public static final String MT_PROTOBUF
- See Also:
- Constant Field Values
-
-
Method Detail
-
login
public void login(String tokenUrl, String username, char[] password) throws ClientException
- Throws:
ClientException
-
loginWithAuthorizationCode
public void loginWithAuthorizationCode(String tokenUrl, String authorizationCode) throws ClientException
- Throws:
ClientException
-
refreshAccessToken
public void refreshAccessToken() throws ClientException
- Throws:
ClientException
-
getCredentials
public Credentials getCredentials()
-
doAsyncRequest
public CompletableFuture<byte[]> doAsyncRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, byte[] body) throws ClientException, IOException, GeneralSecurityException
-
doAsyncRequest
public CompletableFuture<byte[]> doAsyncRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, byte[] body, io.netty.handler.codec.http.HttpHeaders extraHeaders) throws ClientException, IOException, GeneralSecurityException
-
doBulkSendRequest
public CompletableFuture<BulkRestDataSender> doBulkSendRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod) throws ClientException, IOException, GeneralSecurityException
-
setMaxResponseLength
public void setMaxResponseLength(int length)
Sets the maximum size of the responses - this is not applicable to bulk requests whose response is practically unlimited and delivered piece by piece- Parameters:
length
-
-
doBulkReceiveRequest
public CompletableFuture<Void> doBulkReceiveRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, byte[] body, BulkRestDataReceiver receiver) throws ClientException, IOException, GeneralSecurityException
Perform a request that potentially retrieves large amount of data. The data is forwarded to the client.- Parameters:
receiver
- send all the data to this receiver. To find out when the request has been finished, the Future has to be used- Returns:
- a future indicating when the operation is completed.
- Throws:
GeneralSecurityException
IOException
ClientException
-
doBulkRequest
public CompletableFuture<Void> doBulkRequest(String url, io.netty.handler.codec.http.HttpMethod httpMethod, String body, BulkRestDataReceiver receiver) throws ClientException, IOException, GeneralSecurityException
-
setCaCertFile
public void setCaCertFile(String caCertFile) throws IOException, GeneralSecurityException
In case of https connections, this file contains the CA certificates that are used to verify server certificate- Parameters:
caCertFile
-- Throws:
IOException
GeneralSecurityException
-
isInsecureTls
public boolean isInsecureTls()
-
setInsecureTls
public void setInsecureTls(boolean insecureTls)
if true and https connections are used, do not verify server certificate- Parameters:
insecureTls
-
-
addCookie
public void addCookie(io.netty.handler.codec.http.cookie.Cookie c)
-
getCookies
public List<io.netty.handler.codec.http.cookie.Cookie> getCookies()
-
getSendMediaType
public String getSendMediaType()
-
setSendMediaType
public void setSendMediaType(String sendMediaType)
-
getAcceptMediaType
public String getAcceptMediaType()
-
setAcceptMediaType
public void setAcceptMediaType(String acceptMediaType)
-
close
public void close()
-
-