mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-24 00:11:23 +00:00
77 lines
3.8 KiB
HTML
77 lines
3.8 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ImpatientHttpConnector.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub API for Java</a> > <a href="index.source.html" class="el_package">org.kohsuke.github.extras</a> > <span class="el_source">ImpatientHttpConnector.java</span></div><h1>ImpatientHttpConnector.java</h1><pre class="source lang-java linenums">package org.kohsuke.github.extras;
|
|
|
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
|
import org.kohsuke.github.HttpConnector;
|
|
|
|
import java.io.IOException;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/**
|
|
* {@link HttpConnector} wrapper that sets timeout
|
|
*
|
|
* @author Kohsuke Kawaguchi
|
|
*/
|
|
public class ImpatientHttpConnector implements HttpConnector {
|
|
private final HttpConnector base;
|
|
private final int readTimeout, connectTimeout;
|
|
|
|
/**
|
|
* Instantiates a new Impatient http connector.
|
|
*
|
|
* @param base
|
|
* the base
|
|
* @param connectTimeout
|
|
* HTTP connection timeout in milliseconds
|
|
* @param readTimeout
|
|
* HTTP read timeout in milliseconds
|
|
*/
|
|
<span class="fc" id="L30"> public ImpatientHttpConnector(HttpConnector base, int connectTimeout, int readTimeout) {</span>
|
|
<span class="fc" id="L31"> this.base = base;</span>
|
|
<span class="fc" id="L32"> this.connectTimeout = connectTimeout;</span>
|
|
<span class="fc" id="L33"> this.readTimeout = readTimeout;</span>
|
|
<span class="fc" id="L34"> }</span>
|
|
|
|
/**
|
|
* Instantiates a new Impatient http connector.
|
|
*
|
|
* @param base
|
|
* the base
|
|
* @param timeout
|
|
* the timeout
|
|
*/
|
|
public ImpatientHttpConnector(HttpConnector base, int timeout) {
|
|
<span class="nc" id="L45"> this(base, timeout, timeout);</span>
|
|
<span class="nc" id="L46"> }</span>
|
|
|
|
/**
|
|
* Instantiates a new Impatient http connector.
|
|
*
|
|
* @param base
|
|
* the base
|
|
*/
|
|
public ImpatientHttpConnector(HttpConnector base) {
|
|
<span class="fc" id="L55"> this(base, CONNECT_TIMEOUT, READ_TIMEOUT);</span>
|
|
<span class="fc" id="L56"> }</span>
|
|
|
|
public HttpURLConnection connect(URL url) throws IOException {
|
|
<span class="fc" id="L59"> HttpURLConnection con = base.connect(url);</span>
|
|
<span class="fc" id="L60"> con.setConnectTimeout(connectTimeout);</span>
|
|
<span class="fc" id="L61"> con.setReadTimeout(readTimeout);</span>
|
|
<span class="fc" id="L62"> return con;</span>
|
|
}
|
|
|
|
/**
|
|
* Default connection timeout in milliseconds
|
|
*/
|
|
@SuppressFBWarnings("MS_SHOULD_BE_FINAL")
|
|
<span class="fc" id="L69"> public static int CONNECT_TIMEOUT = (int) TimeUnit.SECONDS.toMillis(10);</span>
|
|
|
|
/**
|
|
* Default read timeout in milliseconds
|
|
*/
|
|
@SuppressFBWarnings("MS_SHOULD_BE_FINAL")
|
|
<span class="fc" id="L75"> public static int READ_TIMEOUT = (int) TimeUnit.SECONDS.toMillis(10);</span>
|
|
}
|
|
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html> |