Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 28 for if (0.14 sec)

  1. samples/static-server/src/main/java/okhttp3/sample/SampleServer.java

        return result;
      }
    
      private String contentType(String path) {
        if (path.endsWith(".png")) return "image/png";
        if (path.endsWith(".jpg")) return "image/jpeg";
        if (path.endsWith(".jpeg")) return "image/jpeg";
        if (path.endsWith(".gif")) return "image/gif";
        if (path.endsWith(".html")) return "text/html; charset=utf-8";
        if (path.endsWith(".txt")) return "text/plain; charset=utf-8";
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Wed Jan 02 02:50:44 GMT 2019
    - 4.7K bytes
    - Viewed (0)
  2. samples/slack/src/main/java/okhttp3/slack/SlackApi.java

        @ToJson String urlToJson(HttpUrl httpUrl) {
          return httpUrl.toString();
        }
    
        @FromJson HttpUrl urlFromJson(String urlString) {
          if (urlString.startsWith("wss:")) urlString = "https:" + urlString.substring(4);
          if (urlString.startsWith("ws:")) urlString = "http:" + urlString.substring(3);
          return HttpUrl.get(urlString);
        }
      }
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Fri Jul 06 19:30:55 GMT 2018
    - 4.4K bytes
    - Viewed (1)
  3. samples/guide/src/main/java/okhttp3/recipes/PostStreaming.java

              int x = n / i;
              if (x * i == n) return factor(x) + " × " + i;
            }
            return Integer.toString(n);
          }
        };
    
        Request request = new Request.Builder()
            .url("https://api.github.com/markdown/raw")
            .post(requestBody)
            .build();
    
        try (Response response = client.newCall(request).execute()) {
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Fri Jul 06 03:18:15 GMT 2018
    - 2.1K bytes
    - Viewed (0)
  4. samples/guide/src/main/java/okhttp3/recipes/PostFile.java

            .url("https://api.github.com/markdown/raw")
            .post(RequestBody.create(file, MEDIA_TYPE_MARKDOWN))
            .build();
    
        try (Response response = client.newCall(request).execute()) {
          if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
    
          System.out.println(response.body().string());
        }
      }
    
      public static void main(String... args) throws Exception {
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat May 25 18:02:55 GMT 2019
    - 1.5K bytes
    - Viewed (0)
  5. samples/guide/src/main/java/okhttp3/recipes/Progress.java

          boolean firstUpdate = true;
    
          @Override public void update(long bytesRead, long contentLength, boolean done) {
            if (done) {
              System.out.println("completed");
            } else {
              if (firstUpdate) {
                firstUpdate = false;
                if (contentLength == -1) {
                  System.out.println("content-length: unknown");
                } else {
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat Jan 12 03:31:36 GMT 2019
    - 3.9K bytes
    - Viewed (0)
  6. samples/slack/src/main/java/okhttp3/slack/RtmSession.java

        System.out.println("onFailure " + response);
      }
    
      @Override public void close() throws IOException {
        if (webSocket == null) return;
    
        WebSocket webSocket;
        synchronized (this) {
          webSocket = this.webSocket;
        }
    
        if (webSocket != null) {
          webSocket.close(1000, "bye");
        }
      }
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat Nov 19 20:16:58 GMT 2016
    - 2.4K bytes
    - Viewed (0)
  7. samples/guide/src/main/java/okhttp3/recipes/RequestBodyCompression.java

    import okhttp3.RequestBody;
    import okhttp3.Response;
    import okio.BufferedSink;
    import okio.GzipSink;
    import okio.Okio;
    
    public final class RequestBodyCompression {
      /**
       * The Google API KEY for OkHttp recipes. If you're using Google APIs for anything other than
       * running these examples, please request your own client ID!
       *
       * https://console.developers.google.com/project
       */
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat May 25 18:02:55 GMT 2019
    - 3.8K bytes
    - Viewed (0)
  8. samples/guide/src/main/java/okhttp3/recipes/CheckHandshake.java

        @Override public Response intercept(Chain chain) throws IOException {
          for (Certificate certificate : chain.connection().handshake().peerCertificates()) {
            String pin = CertificatePinner.pin(certificate);
            if (denylist.contains(pin)) {
              throw new IOException("Denylisted peer certificate: " + pin);
            }
          }
          return chain.proceed(chain.request());
        }
      };
    
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Apr 15 14:55:09 GMT 2024
    - 2.1K bytes
    - Viewed (0)
  9. samples/guide/src/main/java/okhttp3/recipes/RewriteResponseCacheControl.java

          Request request = new Request.Builder()
              .url("https://api.github.com/search/repositories?q=http")
              .build();
    
          OkHttpClient clientForCall;
          if (i == 2) {
            // Force this request's response to be written to the cache. This way, subsequent responses
            // can be read from the cache.
            System.out.println("Force cache: true");
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Sat Jan 12 03:31:36 GMT 2019
    - 2.6K bytes
    - Viewed (0)
  10. samples/guide/src/main/java/okhttp3/recipes/PostStreamingWithPipe.java

            .post(pipeBody)
            .build();
    
        streamPrimesToSinkAsynchronously(pipeBody.sink());
    
        try (Response response = client.newCall(request).execute()) {
          if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
    
          System.out.println(response.body().string());
        }
      }
    
      private void streamPrimesToSinkAsynchronously(final BufferedSink sink) {
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Fri Jul 06 03:18:15 GMT 2018
    - 3.1K bytes
    - Viewed (0)
Back to top