当前位置: 首页>>代码示例>>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;未经允许,请勿转载。