當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpEngine類代碼示例

本文整理匯總了Java中com.squareup.okhttp.internal.http.HttpEngine的典型用法代碼示例。如果您正苦於以下問題:Java HttpEngine類的具體用法?Java HttpEngine怎麽用?Java HttpEngine使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HttpEngine類屬於com.squareup.okhttp.internal.http包,在下文中一共展示了HttpEngine類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cancel

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
public synchronized void cancel(Object tag) {
    for (AsyncCall call : this.readyCalls) {
        if (Util.equal(tag, call.tag())) {
            call.cancel();
        }
    }
    for (AsyncCall call2 : this.runningCalls) {
        if (Util.equal(tag, call2.tag())) {
            call2.get().canceled = true;
            HttpEngine engine = call2.get().engine;
            if (engine != null) {
                engine.cancel();
            }
        }
    }
    for (Call call3 : this.executedCalls) {
        if (Util.equal(tag, call3.tag())) {
            call3.cancel();
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:Dispatcher.java

示例2: update

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
private void update(CacheResponse conditionalCacheHit, HttpURLConnection httpConnection)
    throws IOException {
  HttpEngine httpEngine = getHttpEngine(httpConnection);
  URI uri = httpEngine.getUri();
  ResponseHeaders response = httpEngine.getResponseHeaders();
  RawHeaders varyHeaders =
      httpEngine.getRequestHeaders().getHeaders().getAll(response.getVaryFields());
  Entry entry = new Entry(uri, varyHeaders, httpConnection);
  DiskLruCache.Snapshot snapshot = (conditionalCacheHit instanceof EntryCacheResponse)
      ? ((EntryCacheResponse) conditionalCacheHit).snapshot
      : ((EntrySecureCacheResponse) conditionalCacheHit).snapshot;
  DiskLruCache.Editor editor = null;
  try {
    editor = snapshot.edit(); // returns null if snapshot is not current
    if (editor != null) {
      entry.writeTo(editor);
      editor.commit();
    }
  } catch (IOException e) {
    abortQuietly(editor);
  }
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:23,代碼來源:HttpResponseCache.java

示例3: getErrorStream

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
public final InputStream getErrorStream() {
    InputStream inputStream = null;
    try {
        HttpEngine response = getResponse();
        if (HttpEngine.hasBody(response.getResponse()) && response.getResponse().code() >=
                400) {
            inputStream = response.getResponse().body().byteStream();
        }
    } catch (IOException e) {
    }
    return inputStream;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:HttpURLConnectionImpl.java

示例4: getInputStream

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
public final InputStream getInputStream() throws IOException {
    if (this.doInput) {
        HttpEngine response = getResponse();
        if (getResponseCode() < 400) {
            return response.getResponse().body().byteStream();
        }
        throw new FileNotFoundException(this.url.toString());
    }
    throw new ProtocolException("This protocol does not support input");
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:HttpURLConnectionImpl.java

示例5: newHttpEngine

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
private HttpEngine newHttpEngine(String method, StreamAllocation streamAllocation,
                                 RetryableSink requestBody, Response priorResponse) throws
        MalformedURLException, UnknownHostException {
    Request.Builder builder = new Request.Builder().url(Internal.instance.getHttpUrlChecked
            (getURL().toString())).method(method, HttpMethod.requiresRequestBody(method) ?
            EMPTY_REQUEST_BODY : null);
    Headers headers = this.requestHeaders.build();
    int size = headers.size();
    for (int i = 0; i < size; i++) {
        builder.addHeader(headers.name(i), headers.value(i));
    }
    boolean bufferRequestBody = false;
    if (HttpMethod.permitsRequestBody(method)) {
        if (this.fixedContentLength != -1) {
            builder.header("Content-Length", Long.toString(this.fixedContentLength));
        } else if (this.chunkLength > 0) {
            builder.header("Transfer-Encoding", "chunked");
        } else {
            bufferRequestBody = true;
        }
        if (headers.get("Content-Type") == null) {
            builder.header("Content-Type", Client.FormMime);
        }
    }
    if (headers.get(Network.USER_AGENT) == null) {
        builder.header(Network.USER_AGENT, defaultUserAgent());
    }
    Request request = builder.build();
    OkHttpClient engineClient = this.client;
    if (!(Internal.instance.internalCache(engineClient) == null || getUseCaches())) {
        engineClient = this.client.clone().setCache(null);
    }
    return new HttpEngine(engineClient, request, bufferRequestBody, true, false,
            streamAllocation, requestBody, priorResponse);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:36,代碼來源:HttpURLConnectionImpl.java

示例6: getResponse

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
private HttpEngine getResponse() throws IOException {
    initHttpEngine();
    if (this.httpEngine.hasResponse()) {
        return this.httpEngine;
    }
    while (true) {
        if (execute(true)) {
            Response response = this.httpEngine.getResponse();
            Request followUp = this.httpEngine.followUpRequest();
            if (followUp == null) {
                this.httpEngine.releaseStreamAllocation();
                return this.httpEngine;
            }
            int i = this.followUpCount + 1;
            this.followUpCount = i;
            if (i > 20) {
                throw new ProtocolException("Too many follow-up requests: " + this
                        .followUpCount);
            }
            this.url = followUp.url();
            this.requestHeaders = followUp.headers().newBuilder();
            Sink requestBody = this.httpEngine.getRequestBody();
            if (!followUp.method().equals(this.method)) {
                requestBody = null;
            }
            if (requestBody == null || (requestBody instanceof RetryableSink)) {
                StreamAllocation streamAllocation = this.httpEngine.close();
                if (!this.httpEngine.sameConnection(followUp.httpUrl())) {
                    streamAllocation.release();
                    streamAllocation = null;
                }
                this.httpEngine = newHttpEngine(followUp.method(), streamAllocation,
                        (RetryableSink) requestBody, response);
            } else {
                throw new HttpRetryException("Cannot retry streamed HTTP body", this
                        .responseCode);
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:41,代碼來源:HttpURLConnectionImpl.java

示例7: newEngine

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
HttpEngine newEngine(Connection connection) throws IOException {
  String protocol = request.url().getProtocol();
  RawHeaders requestHeaders = request.rawHeaders();
  if (protocol.equals("http")) {
    return new HttpEngine(client, this, request.method(), requestHeaders, connection, null);
  } else if (protocol.equals("https")) {
    return new HttpsEngine(client, this, request.method(), requestHeaders, connection, null);
  } else {
    throw new AssertionError();
  }
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:12,代碼來源:Job.java

示例8: getHttpEngine

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
private HttpEngine getHttpEngine(URLConnection httpConnection) {
  if (httpConnection instanceof HttpURLConnectionImpl) {
    return ((HttpURLConnectionImpl) httpConnection).getHttpEngine();
  } else if (httpConnection instanceof HttpsURLConnectionImpl) {
    return ((HttpsURLConnectionImpl) httpConnection).getHttpEngine();
  } else {
    return null;
  }
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:10,代碼來源:HttpResponseCache.java

示例9: getSslSocket

import com.squareup.okhttp.internal.http.HttpEngine; //導入依賴的package包/類
/**
 * Returns the SSL socket used by {@code httpConnection} for HTTPS, nor null
 * if the connection isn't using HTTPS. Since we permit redirects across
 * protocols (HTTP to HTTPS or vice versa), the implementation type of the
 * connection doesn't necessarily match the implementation type of its HTTP
 * engine.
 */
private SSLSocket getSslSocket(HttpURLConnection httpConnection) {
  HttpEngine engine = httpConnection instanceof HttpsURLConnectionImpl
      ? ((HttpsURLConnectionImpl) httpConnection).getHttpEngine()
      : ((HttpURLConnectionImpl) httpConnection).getHttpEngine();
  return engine instanceof HttpsEngine
      ? ((HttpsEngine) engine).getSslSocket()
      : null;
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:16,代碼來源:HttpResponseCache.java


注:本文中的com.squareup.okhttp.internal.http.HttpEngine類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。