keycloak
公開メンバ関数 | 関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.keycloak.broker.provider.util.SimpleHttp.Response クラス
org.keycloak.broker.provider.util.SimpleHttp.Response 連携図
Collaboration graph

公開メンバ関数

 Response (HttpResponse response)
 
int getStatus () throws IOException
 
JsonNode asJson () throws IOException
 
String asString () throws IOException
 
String getFirstHeader (String name) throws IOException
 
void close () throws IOException
 

関数

public< T > T asJson (Class< T > type) throws IOException
 
public< T > T asJson (TypeReference< T > type) throws IOException
 

非公開メンバ関数

void readResponse () throws IOException
 

非公開変数類

HttpResponse response
 
int statusCode = -1
 
String responseString
 

詳解

構築子と解体子

◆ Response()

org.keycloak.broker.provider.util.SimpleHttp.Response.Response ( HttpResponse  response)
inline
243  {
244  this.response = response;
245  }
HttpResponse response
Definition: SimpleHttp.java:239

関数詳解

◆ asJson() [1/3]

JsonNode org.keycloak.broker.provider.util.SimpleHttp.Response.asJson ( ) throws IOException
inline
288  {
289  return mapper.readTree(asString());
290  }
static final ObjectMapper mapper
Definition: SimpleHttp.java:60
String asString()
Definition: SimpleHttp.java:300

◆ asJson() [2/3]

public<T> T org.keycloak.broker.provider.util.SimpleHttp.Response.asJson ( Class< T >  type) throws IOException
inlinepackage
292  {
293  return JsonSerialization.readValue(asString(), type);
294  }
String asString()
Definition: SimpleHttp.java:300

◆ asJson() [3/3]

public<T> T org.keycloak.broker.provider.util.SimpleHttp.Response.asJson ( TypeReference< T >  type) throws IOException
inlinepackage
296  {
297  return JsonSerialization.readValue(asString(), type);
298  }
String asString()
Definition: SimpleHttp.java:300

◆ asString()

String org.keycloak.broker.provider.util.SimpleHttp.Response.asString ( ) throws IOException
inline
300  {
301  readResponse();
302  return responseString;
303  }
void readResponse()
Definition: SimpleHttp.java:247
String responseString
Definition: SimpleHttp.java:241

◆ close()

void org.keycloak.broker.provider.util.SimpleHttp.Response.close ( ) throws IOException
inline
310  {
311  readResponse();
312  }
void readResponse()
Definition: SimpleHttp.java:247

◆ getFirstHeader()

String org.keycloak.broker.provider.util.SimpleHttp.Response.getFirstHeader ( String  name) throws IOException
inline
305  {
306  readResponse();
307  return response.getHeaders(name)[0].getValue();
308  }
void readResponse()
Definition: SimpleHttp.java:247
HttpResponse response
Definition: SimpleHttp.java:239

◆ getStatus()

int org.keycloak.broker.provider.util.SimpleHttp.Response.getStatus ( ) throws IOException
inline
283  {
284  readResponse();
285  return response.getStatusLine().getStatusCode();
286  }
void readResponse()
Definition: SimpleHttp.java:247
HttpResponse response
Definition: SimpleHttp.java:239

◆ readResponse()

void org.keycloak.broker.provider.util.SimpleHttp.Response.readResponse ( ) throws IOException
inlineprivate
247  {
248  if (statusCode == -1) {
249  statusCode = response.getStatusLine().getStatusCode();
250 
251  InputStream is;
252  HttpEntity entity = response.getEntity();
253  if (entity != null) {
254  is = entity.getContent();
255  try {
256  HeaderIterator it = response.headerIterator();
257  while (it.hasNext()) {
258  Header header = it.nextHeader();
259  if (header.getName().equals("Content-Encoding") && header.getValue().equals("gzip")) {
260  is = new GZIPInputStream(is);
261  }
262  }
263 
264  InputStreamReader reader = new InputStreamReader(is);
265 
266  StringWriter writer = new StringWriter();
267 
268  char[] buffer = new char[1024 * 4];
269  for (int n = reader.read(buffer); n != -1; n = reader.read(buffer)) {
270  writer.write(buffer, 0, n);
271  }
272 
273  responseString = writer.toString();
274  } finally {
275  if (is != null) {
276  is.close();
277  }
278  }
279  }
280  }
281  }
SimpleHttp header(String name, String value)
Definition: SimpleHttp.java:100
Object entity
Definition: SimpleHttp.java:68
int statusCode
Definition: SimpleHttp.java:240
HttpResponse response
Definition: SimpleHttp.java:239
String responseString
Definition: SimpleHttp.java:241

メンバ詳解

◆ response

HttpResponse org.keycloak.broker.provider.util.SimpleHttp.Response.response
private

◆ responseString

String org.keycloak.broker.provider.util.SimpleHttp.Response.responseString
private

◆ statusCode

int org.keycloak.broker.provider.util.SimpleHttp.Response.statusCode = -1
private

このクラス詳解は次のファイルから抽出されました: