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

com.sinch.sdk.core.http.HttpResponse Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.sinch.sdk.core.http;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class HttpResponse {

  private final int code;

  private final String message;

  private final Map> headers;

  private final byte[] buffer;

  public HttpResponse(
      final int code,
      final String message,
      final Map> headers,
      final byte[] buffer) {
    this.code = code;
    this.message = null != message ? message : "";
    this.headers = (null != headers) ? headers : Collections.emptyMap();
    this.buffer = null != buffer ? buffer : "".getBytes(StandardCharsets.UTF_8);
  }

  public int getCode() {
    return code;
  }

  public String getMessage() {
    return message;
  }

  public Map> getHeaders() {
    return headers;
  }

  public InputStream getContent() {
    return new ByteArrayInputStream(buffer);
  }

  @Override
  public String toString() {
    return "HttpResponse{"
        + "code="
        + code
        + ", message='"
        + message
        + '\''
        + ", headers="
        + headers
        + ", buffer="
        + new String(buffer)
        + '}';
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy