コード例 #1
0
ファイル: AuthContext.java プロジェクト: vilterp/hitman
  public Either<IOException, HttpResponse> execRequest(HttpUriRequest httpReq, String acceptType) {
    DefaultHttpClient httpClient = new DefaultHttpClient();
    httpReq.setHeader("accept", acceptType);
    for (Header header : getHeaders()) {
      httpReq.setHeader(header);
    }

    try {
      HttpResponse resp = httpClient.execute(httpReq);
      Log.i(
          TAG,
          String.format(
              "%s %s %s => %d",
              httpReq.getRequestLine().getMethod(),
              httpReq.getRequestLine().getUri(),
              httpReq.getParams(),
              resp.getStatusLine().getStatusCode()));
      return new Right<IOException, HttpResponse>(resp);
    } catch (IOException e) {
      return new Left<IOException, HttpResponse>(e);
    }
  }