コード例 #1
0
ファイル: RESTConcurrencyTest.java プロジェクト: dirkk/basex
    @Override
    public HTTPResponse call() throws Exception {
      final HttpURLConnection hc = (HttpURLConnection) uri.toURL().openConnection();
      hc.setReadTimeout(SOCKET_TIMEOUT);
      try {
        while (!stop) {
          try {
            final int code = hc.getResponseCode();

            final InputStream input = hc.getInputStream();
            final ByteList bl = new ByteList();
            for (int i; (i = input.read()) != -1; ) bl.add(i);

            return new HTTPResponse(code, bl.toString());
          } catch (final SocketTimeoutException e) {
          }
        }
        return null;
      } finally {
        hc.disconnect();
      }
    }
コード例 #2
0
ファイル: BufferInput.java プロジェクト: godmar/basex
 /**
  * Returns the next unsigned byte (see {@link InputStream#read}. {@code -1} is returned if all
  * bytes have been read.
  *
  * @return next unsigned byte
  * @throws IOException I/O exception
  */
 protected int next() throws IOException {
   final int blen = buffer.length;
   final byte[] buf = buffer;
   if (bpos >= bsize) {
     if (bsize == 0 || bsize == blen) {
       // reset mark if buffer is full
       if (bsize == blen) bmark = -1;
       // buffer is empty or full: re-fill it
       bsize = 0;
       bpos = 0;
     }
     int r;
     while ((r = in.read(buf, bsize, blen - bsize)) == 0) ;
     if (r < 0) return -1;
     bsize += r;
     read += r;
   }
   return buf[bpos++] & 0xFF;
 }
コード例 #3
0
ファイル: BufferInput.java プロジェクト: godmar/basex
 @Override
 public final void close() throws IOException {
   if (in != null && !(in instanceof ZipInputStream)) in.close();
 }