/** * Loads paginated resources. * * Every iterator call reports a new batch. */ /*package*/ <T> Iterator<T> asIterator(String tailApiUrl, Class<T> type, int pageSize) { method("GET"); if (pageSize!=0) args.add(new Entry("per_page",pageSize)); StringBuilder s = new StringBuilder(tailApiUrl); if (!args.isEmpty()) { boolean first = true; try { for (Entry a : args) { s.append(first ? '?' : '&'); first = false; s.append(URLEncoder.encode(a.key, "UTF-8")); s.append('='); s.append(URLEncoder.encode(a.value.toString(), "UTF-8")); } } catch (UnsupportedEncodingException e) { throw new AssertionError(e); // UTF-8 is mandatory } } try { return new PagingIterator<T>(type, tailApiUrl, root.getApiURL(s.toString())); } catch (IOException e) { throw new GHException("Unable to build github Api URL",e); } }
/** * Loads paginated resources. * * Every iterator call reports a new batch. */ /*package*/ <T> Iterator<T> asIterator(String tailApiUrl, Class<T> type, int pageSize) { method("GET"); if (pageSize!=0) args.add(new Entry("per_page",pageSize)); StringBuilder s = new StringBuilder(tailApiUrl); if (!args.isEmpty()) { boolean first = true; try { for (Entry a : args) { s.append(first ? '?' : '&'); first = false; s.append(URLEncoder.encode(a.key, "UTF-8")); s.append('='); s.append(URLEncoder.encode(a.value.toString(), "UTF-8")); } } catch (UnsupportedEncodingException e) { throw new AssertionError(e); // UTF-8 is mandatory } } try { return new PagingIterator<T>(type, tailApiUrl, root.getApiURL(s.toString())); } catch (IOException e) { throw new GHException("Unable to build github Api URL",e); } }
HttpURLConnection uc = getConnector().connect(getApiURL("/"));
setupConnection(root.getApiURL(tailApiUrl));
/** * Makes a request and just obtains the HTTP status code. */ public int asHttpStatusCode(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit setupConnection(root.getApiURL(tailApiUrl)); buildRequest(); try { return uc.getResponseCode(); } catch (IOException e) { handleApiError(e); } } }
HttpURLConnection uc = getConnector().connect(getApiURL("/"));
url = root.getApiURL(tailApiUrl); } catch (IOException e) { throw new Error(e);
public InputStream asStream(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit setupConnection(root.getApiURL(tailApiUrl)); buildRequest(); try { return wrapStream(uc.getInputStream()); } catch (IOException e) { handleApiError(e); } } }
setupConnection(root.getApiURL(tailApiUrl));
setupConnection(root.getApiURL(tailApiUrl));
public InputStream asStream(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit setupConnection(root.getApiURL(tailApiUrl)); buildRequest(); try { return wrapStream(uc.getInputStream()); } catch (IOException e) { handleApiError(e); } finally { noteRateLimit(tailApiUrl); } } }
public InputStream asStream(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit setupConnection(root.getApiURL(tailApiUrl)); buildRequest(); try { return wrapStream(uc.getInputStream()); } catch (IOException e) { handleApiError(e); } finally { noteRateLimit(tailApiUrl); } } }
/** * Makes a request and just obtains the HTTP status code. */ public int asHttpStatusCode(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit method("GET"); setupConnection(root.getApiURL(tailApiUrl)); buildRequest(); try { return uc.getResponseCode(); } catch (IOException e) { handleApiError(e); } finally { noteRateLimit(tailApiUrl); } } }
/** * Makes a request and just obtains the HTTP status code. */ public int asHttpStatusCode(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit method("GET"); setupConnection(root.getApiURL(tailApiUrl)); buildRequest(); try { return uc.getResponseCode(); } catch (IOException e) { handleApiError(e); } finally { noteRateLimit(tailApiUrl); } } }