1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-12 10:23:16 +03:00

Merge pull request #5202 from ajalt/aj/mkdocs

Use MkDocs to generate website
This commit is contained in:
Jesse Wilson
2019-06-19 21:52:38 -04:00
committed by GitHub
32 changed files with 283 additions and 655 deletions

View File

@@ -9,7 +9,7 @@ _2019-06-03_
bugs or performance regressions before the final 4.0.0 release.
We tried our best to make it fast and safe to upgrade from OkHttp 3.x.
[We even wrote a guide](UPGRADING_TO_OKHTTP_4.md) to help you with it!
[We even wrote a guide](docs/upgrading_to_okhttp_4.md) to help you with it!
## Version 3.14.2
@@ -1304,7 +1304,7 @@ _2014-12-30_
running SSLv3, you must manually configure your own `ConnectionSpec`.
* **OkHttp now offers interceptors.** Interceptors are a powerful mechanism
that can monitor, rewrite, and retry calls. The [interceptors doc](INTERCEPTORS.md) is a full
that can monitor, rewrite, and retry calls. The [interceptors doc](docs/interceptors.md) is a full
introduction to this new API.
* New: APIs to iterate and selectively clear the response cache.
@@ -1787,5 +1787,5 @@ Initial release.
[require_android_5]: https://medium.com/square-corner-blog/okhttp-3-13-requires-android-5-818bb78d07ce
[obsolete_apache_client]: https://gist.github.com/swankjesse/09721f72039e3a46cf50f94323deb82d
[obsolete_url_factory]: https://gist.github.com/swankjesse/dd91c0a8854e1559b00f5fc9c7bfae70
[tls_configuration_history]: TLS_CONFIGURATION_HISTORY.md
[tls_configuration_history]: docs/tls_configuration_history.md
[grpc_http2]: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md

View File

@@ -9,7 +9,7 @@ If you've found a security problem, please follow our [bug bounty](BUG-BOUNTY.md
If you've found a bug, please contribute a failing test case so we can study and fix it.
If you have a new feature idea, please build it in an external library. There are
[many libraries](WORKS_WITH_OKHTTP.md) that sit on top or hook in via existing APIs. If you build
[many libraries](./docs/works_with_okhttp.md) that sit on top or hook in via existing APIs. If you build
something that integrates with OkHttp, tell us so that we can link it!
Before code can be accepted all contributors must complete our
@@ -35,5 +35,5 @@ squash all pull requests on merge.
Committer's Guides
------------------
* [Concurrency](CONCURRENCY.md)
* [Concurrency](./docs/concurrency.md)
* [Releasing](RELEASING.md)

View File

@@ -6,8 +6,8 @@ An HTTP & HTTP/2 client for Android and Java applications.
Docs
----
* [**User's Guide**](CALLS.md) (includes [Calls](CALLS.md), [Connections](CONNECTIONS.md),
[Recipes](RECIPES.md), [Interceptors](INTERCEPTORS.md), [HTTPS](HTTPS.md), [Events](EVENTS.md))
* [**User's Guide**](docs/calls.md) (includes [Calls](docs/calls.md), [Connections](docs/connections.md),
[Recipes](docs/recipes.md), [Interceptors](docs/interceptors.md), [HTTPS](docs/https.md), [Events](docs/events.md))
* [**4.x API**][4x_okhttp] (also [dnsoverhttps][4x_dnsoverhttps],
[logging-interceptor][4x_logging], [sse][4x_sse], [tls][4x_tls],
[urlconnection][4x_urlconnection], [mockwebserver][4x_mockwebserver])
@@ -15,7 +15,7 @@ Docs
[logging-interceptor][3x_logging], [sse][3x_sse], [tls][3x_tls],
[urlconnection][3x_urlconnection], [mockwebserver][3x_mockwebserver])
* [**StackOverflow**](http://stackoverflow.com/questions/tagged/okhttp?sort=active)
* [**Works with OkHttp**](WORKS_WITH_OKHTTP.md)
* [**Works with OkHttp**](docs/works_with_okhttp.md)
Requirements
@@ -91,7 +91,7 @@ License
[okhttp_312x]: https://github.com/square/okhttp/tree/okhttp_3.12.x
[okio]: https://github.com/square/okio/
[snap]: https://oss.sonatype.org/content/repositories/snapshots/
[tls_history]: TLS_CONFIGURATION_HISTORY.md
[tls_history]: docs/tls_configuration_history.md
[website]: https://square.github.io/okhttp
[okhttp3_pro]: https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro

View File

@@ -156,20 +156,24 @@ subprojects { project ->
}
}
dokka {
reportUndocumented = false
skipDeprecated = true
jdkVersion = 8
packageOptions {
prefix = "okhttp3.internal"
suppress = true
}
if (project.file('Module.md').exists()) {
includes = ['Module.md']
}
externalDocumentationLink {
url = new URL("https://square.github.io/okio/2.x/okio/jvm/index.html")
packageListUrl = new URL("https://square.github.io/okio/2.x/okio/jvm/package-list")
// We have to set the dokka configuration after evaluation since the com.vanniktech.maven.publish
// plugin overwrites our dokka configuration on projects where it's applied.
afterEvaluate { p ->
p.tasks.dokka {
reportUndocumented = false
skipDeprecated = true
jdkVersion = 8
packageOptions {
prefix = "okhttp3.internal"
suppress = true
}
if (project.file('Module.md').exists()) {
includes = ['Module.md']
}
externalDocumentationLink {
url = new URL("https://square.github.io/okio/2.x/okio/jvm/index.html")
packageListUrl = new URL("https://square.github.io/okio/2.x/okio/jvm/package-list")
}
}
}
}

View File

@@ -1,5 +1,11 @@
#!/bin/bash
# The website is built using MkDocs with the Material theme.
# https://squidfunk.github.io/mkdocs-material/
# It requires Python to run.
# Install the packages with the following command:
# pip install mkdocs mkdocs-material
set -ex
REPO="git@github.com:square/okhttp.git"
@@ -14,22 +20,11 @@ git clone $REPO $DIR
# Move working directory into temp folder
cd $DIR
# Checkout and track the gh-pages branch
git checkout -t origin/gh-pages
# Generate the API docs
./gradlew :okhttp:dokka
# Delete everything that isn't versioned (1.x, 2.x)
ls | grep -E -v '^\d+\.x$' | xargs rm -rf
# Copy website files from real repo
cp -R ../website/* .
# Stage all files in git and create a commit
git add .
git add -u
git commit -m "Website at $(date)"
# Push the new files up to GitHub
git push origin gh-pages
# Build the site and push the new files up to GitHub
mkdocs gh-deploy
# Delete our temp folder
cd ..

View File

@@ -1,17 +1,16 @@
Calls
=====
# Calls
The HTTP clients job is to accept your request and produce its response. This is simple in theory but it gets tricky in practice.
#### [Requests](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Request.html)
## [Requests](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Request.html)
Each HTTP request contains a URL, a method (like `GET` or `POST`), and a list of headers. Requests may also contain a body: a data stream of a specific content type.
#### [Responses](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Response.html)
## [Responses](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Response.html)
The response answers the request with a code (like 200 for success or 404 for not found), headers, and its own optional body.
#### Rewriting Requests
## Rewriting Requests
When you provide OkHttp with an HTTP request, youre describing the request at a high-level: _“fetch me this URL with these headers.”_ For correctness and efficiency, OkHttp rewrites your request before transmitting it.
@@ -19,23 +18,23 @@ OkHttp may add headers that are absent from the original request, including `Con
Some requests will have a cached response. When this cached response isnt fresh, OkHttp can do a _conditional GET_ to download an updated response if its newer than whats cached. This requires headers like `If-Modified-Since` and `If-None-Match` to be added.
#### Rewriting Responses
## Rewriting Responses
If transparent compression was used, OkHttp will drop the corresponding response headers `Content-Encoding` and `Content-Length` because they dont apply to the decompressed response body.
If a conditional GET was successful, responses from the network and cache are merged as directed by the spec.
#### Follow-up Requests
## Follow-up Requests
When your requested URL has moved, the webserver will return a response code like `302` to indicate the documents new URL. OkHttp will follow the redirect to retrieve a final response.
If the response issues an authorization challenge, OkHttp will ask the [`Authenticator`](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Authenticator.html) (if one is configured) to satisfy the challenge. If the authenticator supplies a credential, the request is retried with that credential included.
#### Retrying Requests
## Retrying Requests
Sometimes connections fail: either a pooled connection was stale and disconnected, or the webserver itself couldnt be reached. OkHttp will retry the request with a different route if one is available.
#### [Calls](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Call.html)
## [Calls](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Call.html)
With rewrites, redirects, follow-ups and retries, your simple request may yield many requests and responses. OkHttp uses `Call` to model the task of satisfying your request through however many intermediate requests and responses are necessary. Typically this isnt many! But its comforting to know that your code will continue to work if your URLs are redirected or if you failover to an alternate IP address.
@@ -46,17 +45,8 @@ Calls are executed in one of two ways:
Calls can be canceled from any thread. This will fail the call if it hasnt yet completed! Code that is writing the request body or reading the response body will suffer an `IOException` when its call is canceled.
#### Dispatch
## Dispatch
For synchronous calls, you bring your own thread and are responsible for managing how many simultaneous requests you make. Too many simultaneous connections wastes resources; too few harms latency.
For asynchronous calls, [`Dispatcher`](http://square.github.io/okhttp/3.x/okhttp/okhttp3/Dispatcher.html) implements policy for maximum simultaneous requests. You can set maximums per-webserver (default is 5), and overall (default is 64).
-----
<table><tr>
<td width="25%" align="left"><a href="README.md">← Home</a></td>
<td width="50%" align="center">OkHttp User's Guide</td>
<td width="25%" align="right"><a href="CONNECTIONS.md">Connections →</a></td>
</tr></table>

View File

@@ -41,12 +41,3 @@ When you request a URL with OkHttp, here's what it does:
If there's a problem with the connection, OkHttp will select another route and try again. This allows OkHttp to recover when a subset of a server's addresses are unreachable. It's also useful when a pooled connection is stale or if the attempted TLS version is unsupported.
Once the response has been received, the connection will be returned to the pool so it can be reused for a future request. Connections are evicted from the pool after a period of inactivity.
----
<table><tr>
<td width="25%" align="left"><a href="CALLS.md">← Calls</a></td>
<td width="50%" align="center">OkHttp User's Guide</td>
<td width="25%" align="right"><a href="RECIPES.md">Recipes →</a></td>
</tr></table>

16
docs/css/app.css Normal file
View File

@@ -0,0 +1,16 @@
button.dl {
font-weight: 300;
font-size: 25px;
line-height: 40px;
padding: 3px 10px;
display: inline-block;
border-radius: 6px;
color: #f0f0f0;
margin: 5px 0;
width: auto;
}
.logo {
text-align: center;
margin-top: 150px;
}

View File

@@ -10,7 +10,7 @@ Events allow you to capture metrics on your applications HTTP calls. Use even
Subclass [EventListener](https://square.github.io/okhttp/3.x/okhttp/okhttp3/EventListener.html) and override methods for the events you are interested in. In a successful HTTP call with no redirects or retries the sequence of events is described by this flow.
![Events Diagram](docs/images/events@2x.png)
![Events Diagram](images/events@2x.png)
Heres a [sample event listener](https://github.com/square/okhttp/blob/master/samples/guide/src/main/java/okhttp3/recipes/PrintEventsNonConcurrent.java) that prints each event with a timestamp.
@@ -224,7 +224,7 @@ class MetricsEventListener extends EventListener {
When an operation fails, a failure method is called. This is `connectFailed()` for failures while building a connection to the server, and `callFailed()` when the HTTP call fails permanently. When a failure happens it is possible that a `start` event wont have a corresponding `end` event.
![Events Diagram](docs/images/events_with_failures@2x.png)
![Events Diagram](images/events_with_failures@2x.png)
### Events with Retries and Follow-Ups
@@ -232,17 +232,8 @@ OkHttp is resilient and can automatically recover from some connectivity failure
A single HTTP call may require follow-up requests to be made to handle authentication challenges, redirects, and HTTP-layer timeouts. In such cases multiple connections, requests, and responses may be attempted. Follow-ups are another reason a single call may trigger multiple events of the same type.
![Events Diagram](docs/images/events_with_failures_and_retries@2x.png)
![Events Diagram](images/events_with_failures_and_retries@2x.png)
### Availability
Events is available as a public API in OkHttp 3.11. Future releases may introduce new event types; you will need to override the corresponding methods to handle them.
----
<table><tr>
<td width="25%" align="left"><a href="HTTPS.md">← HTTPS</a></td>
<td width="50%" align="center">OkHttp User's Guide</td>
<td width="25%" align="right"><a href="README.md">Home →</a></td>
</tr></table>

View File

@@ -15,7 +15,7 @@ Specific security vs. connectivity decisions are implemented by [ConnectionSpec]
* `COMPATIBLE_TLS` is a secure configuration that connects to securebut not currentHTTPS servers.
* `CLEARTEXT` is an insecure configuration that is used for `http://` URLs.
These loosely follow the model set in [Google Cloud Policies](https://cloud.google.com/load-balancing/docs/ssl-policies-concepts). We [track changes](TLS_CONFIGURATION_HISTORY.md) to this policy.
These loosely follow the model set in [Google Cloud Policies](https://cloud.google.com/load-balancing/docs/ssl-policies-concepts). We [track changes](tls_configuration_history.md) to this policy.
By default, OkHttp will attempt a `MODERN_TLS` connection. However by configuring the client connectionSpecs you can allow a fall back to `COMPATIBLE_TLS` connection if the modern configuration fails.
@@ -103,12 +103,3 @@ The full code sample shows how to replace the host platforms certificate auth
... // Full source omitted. See sample.
}
```
----
<table><tr>
<td width="25%" align="left"><a href="INTERCEPTORS.md">← Interceptors</a></td>
<td width="50%" align="center">OkHttp User's Guide</td>
<td width="25%" align="right"><a href="EVENTS.md">Events →</a></td>
</tr></table>

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

152
docs/index.md Normal file
View File

@@ -0,0 +1,152 @@
## An HTTP & HTTP/2 client for Android and Java applications
# Overview
HTTP is the way modern applications network. Its how we exchange data &amp; media.
Doing HTTP efficiently makes your stuff load faster and saves bandwidth.
OkHttp is an HTTP client thats efficient by default:
- HTTP/2 support allows all requests to the same host to share a socket.
- Connection pooling reduces request latency (if HTTP/2 isnt available).
- Transparent GZIP shrinks download sizes.
- Response caching avoids the network completely for repeat requests.
OkHttp perseveres when the network is troublesome: it will silently recover from
common connection problems. If your service has multiple IP addresses OkHttp will
attempt alternate addresses if the first connect fails. This is necessary for IPv4+IPv6
and for services hosted in redundant data centers. OkHttp supports modern TLS
features (TLS 1.3, ALPN, certificate pinning). It can be configured to fall back for
broad connectivity.
Using OkHttp is easy. Its request/response API is designed with fluent builders and
immutability. It supports both synchronous blocking calls and async calls with
callbacks.
OkHttp supports Android 5.0+ (API level 21+) and Java 8+.
# Examples
## Get a URL
This program downloads a URL and prints its contents as a string. [Full source][get_example].
```java
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
```
## Post to a Server
This program posts data to a service. [Full source][post_example].
```java
public static final MediaType JSON
= MediaType.get("application/json; charset=utf-8");
OkHttpClient client = new OkHttpClient();
String post(String url, String json) throws IOException {
RequestBody body = RequestBody.create(JSON, json);
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
```
# Download
<button data-md-color-primary="teal" href="https://search.maven.org/remote_content?g=com.squareup.okhttp3&a=okhttp&v=LATEST" class="dl">&darr;&nbsp;Latest&nbsp;JAR</button>
You'll also need [Okio][okio], which OkHttp uses for fast I/O and resizable buffers. Download the
[latest JAR][download_okio]. The source code to OkHttp, its samples, and this website is [available
on GitHub][okhttp].
## Maven
```xml
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>(insert latest version)</version>
</dependency>
```
## Gradle
```groovy
implementation 'com.squareup.okhttp3:okhttp:(insert latest version)'
```
# Contributing
If you would like to contribute code you can do so through GitHub by forking the repository and
sending a pull request. When submitting code, please make every effort to follow existing
conventions and style in order to keep the code as readable as possible. Please also make sure your
code compiles by running `/gradlew check`.
Some general advice
- Dont change public API lightly, avoid if possible, and include your reasoning in the PR if essential. It causes pain for developers who use OkHttp and sometimes runtime errors.
- Favour a working external library if appropriate. There are many examples of OkHttp libraries that can sit on top or hook in via existing APIs.
- Get working code on a personal branch with tests before you submit a PR.
- OkHttp is a small and light dependency. Don't introduce new dependencies or major new functionality.
- OkHttp targets the intersection of RFC correct and widely implemented. Incorrect implementations that are very widely implemented e.g. a bug in Apache, Nginx, Google, Firefox should also be handled.
Before your code can be accepted into the project you must also sign the [Individual Contributor License Agreement (CLA)][cla].
# License
```
Copyright 2016 Square, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
<div class="logo">
<a href="https://squareup.com"><img src="images/logo-square.png" alt="Square, Inc."/></a>
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-40704740-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
[get_example]: https://raw.github.com/square/okhttp/master/samples/guide/src/main/java/okhttp3/guide/GetExample.java
[post_example]: https://raw.github.com/square/okhttp/master/samples/guide/src/main/java/okhttp3/guide/PostExample.java
[download_okio]: https://search.maven.org/remote_content?g=com.squareup.okio&a=okio&v=LATEST
[okio]: https://github.com/square/okio
[okhttp]: https://github.com/square/okhttp
[cla]: https://squ.re/sign-the-cla

View File

@@ -27,7 +27,7 @@ A call to `chain.proceed(request)` is a critical part of each interceptors im
Interceptors can be chained. Suppose you have both a compressing interceptor and a checksumming interceptor: you'll need to decide whether data is compressed and then checksummed, or checksummed and then compressed. OkHttp uses lists to track interceptors, and interceptors are called in order.
![Interceptors Diagram](docs/images/interceptors@2x.png)
![Interceptors Diagram](images/interceptors@2x.png)
#### Application Interceptors
@@ -191,12 +191,3 @@ private static final Interceptor REWRITE_CACHE_CONTROL_INTERCEPTOR = new Interce
```
Typically this approach works best when it complements a corresponding fix on the webserver!
----
<table><tr>
<td width="25%" align="left"><a href="RECIPES.md">← Recipes</a></td>
<td width="50%" align="center">OkHttp User's Guide</td>
<td width="25%" align="right"><a href="HTTPS.md">HTTPS →</a></td>
</tr></table>

View File

@@ -509,12 +509,3 @@ This above code relies on this `responseCount()` method:
return result;
}
```
----
<table><tr>
<td width="25%" align="left"><a href="CONNECTIONS.md">← Connections</a></td>
<td width="50%" align="center">OkHttp User's Guide</td>
<td width="25%" align="right"><a href="INTERCEPTORS.md">Interceptors →</a></td>
</tr></table>

View File

@@ -3,12 +3,13 @@ Security Policy
## Supported Versions
| Version | Supported | Notes |
| ------- | ------------------ | -------------- |
| 4.x | :x: | Not released. |
| 3.14.x | :white_check_mark: | |
| 3.12.x | :white_check_mark: | Android 2.3+ (API level 9+) and Java 7+. Platforms may not support TLSv1.2. Until December 31, 2020 |
| 2.7.x | :x: | Not supported. |
| Version | Supported | Notes |
| ------- | ---------- | -------------- |
| 4.x | | Not released. |
| 3.14.x | | |
| 3.12.x | | Android 2.3+ (API level 9+) and Java 7+. Platforms may not support TLSv1.2. Until December 31, 2020 |
| 2.7.x | | Not supported. |
## Reporting a Vulnerability

50
mkdocs.yml Normal file
View File

@@ -0,0 +1,50 @@
site_name: OkHttp
repo_name: OkHttp
repo_url: https://github.com/square/okhttp
site_description: "An HTTP & HTTP/2 client for Android and Java applications"
site_author: Square, Inc.
remote_branch: gh-pages
copyright: 'Copyright &copy; 2016 Square, Inc.'
theme:
name: 'material'
logo: images/icon-square.png
palette:
primary: 'teal'
accent: 'white'
extra_css:
- 'css/app.css'
markdown_extensions:
- smarty
- codehilite:
guess_lang: false
- footnotes
- meta
- toc:
permalink: true
- pymdownx.betterem:
smart_enable: all
- pymdownx.caret
- pymdownx.inlinehilite
- pymdownx.magiclink
- pymdownx.smartsymbols
- pymdownx.superfences
- tables
nav:
- 'Calls': calls.md
- 'Concurrency': concurrency.md
- 'Connections': connections.md
- 'Events': events.md
- 'Https': https.md
- 'Interceptors': interceptors.md
- 'Recipes': recipes.md
- 'Security': security.md
- 'TLS Configuration History': tls_configuration_history.md
- 'Upgrading to OkHttp 4': upgrading_to_okhttp_4.md
- 'Works with OkHttp': works_with_okhttp.md
- 'Stack Overflow': https://stackoverflow.com/questions/tagged/okhttp?sort=active
- 'API Docs': api/okhttp/okhttp3/index.md

View File

@@ -41,6 +41,13 @@ dependencies {
testCompileOnly deps.jsr305
}
afterEvaluate { project ->
project.tasks.dokka {
outputDirectory = "$rootDir/docs/api"
outputFormat = 'gfm'
}
}
task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: 'jar') {
oldClasspath = files(baselineJar(project, baselineVersion))
newClasspath = files(jar.archivePath)

View File

@@ -1,227 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>OkHttp</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="An HTTP &amp; HTTP/2 client for Android and Java applications">
<link href="static/bootstrap-combined.min.css" rel="stylesheet">
<link href="static/app.css" rel="stylesheet">
<link href="static/app-theme.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,300italic,100,100italic,300" rel="stylesheet" type="text/css">
<!--[if lt IE 9]><script src="static/html5shiv.min.js"></script><![endif]-->
</head>
<body data-target=".content-nav">
<header>
<div class="container">
<div class="row">
<div class="span5">
<h1>OkHttp</h1>
</div>
<div class="span7">
<menu>
<ul>
<li><a href="#download" class="menu download">Download <span class="version-tag">Latest</span></a></li>
<li><a href="https://github.com/square/okhttp" data-title="View GitHub Project" class="menu github"><img src="static/icon-github.png" alt="GitHub"/></a></li>
<li><a href="https://square.github.io/" data-title="Square Open Source Portal" class="menu square"><img src="static/icon-square.png" alt="Square"/></a></li>
</ul>
</menu>
</div>
</div>
</div>
</header>
<section id="subtitle">
<div class="container">
<div class="row">
<div class="span12">
<h2>An <strong>HTTP &amp; HTTP/2</strong> client for Android and Java applications</h2>
</div>
</div>
</div>
</section>
<section id="body">
<div class="container">
<div class="row">
<div class="span9">
<h3 id="overview">Overview</h3>
<p>HTTP is the way modern applications network. Its how we exchange data &amp; media.
Doing HTTP efficiently makes your stuff load faster and saves bandwidth.</p>
<p>OkHttp is an HTTP client thats efficient by default:</p>
<ul>
<li>HTTP/2 support allows all requests to the same host to share a socket.</li>
<li>Connection pooling reduces request latency (if HTTP/2 isnt available).</li>
<li>Transparent GZIP shrinks download sizes.</li>
<li>Response caching avoids the network completely for repeat requests.</li>
</ul>
<p>OkHttp perseveres when the network is troublesome: it will silently recover from
common connection problems. If your service has multiple IP addresses OkHttp will
attempt alternate addresses if the first connect fails. This is necessary for IPv4+IPv6
and for services hosted in redundant data centers. OkHttp supports modern TLS
features (TLS 1.3, ALPN, certificate pinning). It can be configured to fall back for
broad connectivity.</p>
<p>Using OkHttp is easy. Its request/response API is designed with fluent builders and
immutability. It supports both synchronous blocking calls and async calls with
callbacks.</p>
<p>OkHttp supports Android 5.0+ (API level 21+) and Java 8+.</p>
<h3 id="examples">Examples</h3>
<h4>Get a URL</h4>
<p>This program downloads a URL and prints its contents as a string. <a href="https://raw.github.com/square/okhttp/master/samples/guide/src/main/java/okhttp3/guide/GetExample.java">Full source</a>.
<pre class="prettyprint">
OkHttpClient client = new OkHttpClient();
String run(String url) throws IOException {
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
</pre>
<h4>Post to a Server</h4>
<p>This program posts data to a service. <a href="https://raw.github.com/square/okhttp/master/samples/guide/src/main/java/okhttp3/guide/PostExample.java">Full source</a>.
<pre class="prettyprint">
public static final MediaType JSON
= MediaType.get("application/json; charset=utf-8");
OkHttpClient client = new OkHttpClient();
String post(String url, String json) throws IOException {
RequestBody body = RequestBody.create(JSON, json);
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
</pre>
<h3 id="download">Download</h3>
<p><a href="https://search.maven.org/remote_content?g=com.squareup.okhttp3&a=okhttp&v=LATEST" class="dl version-href">&darr; <span class="version-tag">Latest</span> JAR</a></p>
<p>You'll also need <a href="https://github.com/square/okio">Okio</a>, which OkHttp
uses for fast I/O and resizable buffers. Download the
<a href="https://search.maven.org/remote_content?g=com.squareup.okio&a=okio&v=LATEST">latest JAR</a>.
<p>The source code to OkHttp, its samples, and this website is <a href="https://github.com/square/okhttp">available on GitHub</a>.</p>
<h4>Maven</h4>
<pre class="prettyprint">&lt;dependency>
&lt;groupId>com.squareup.okhttp3&lt;/groupId>
&lt;artifactId>okhttp&lt;/artifactId>
&lt;version><span class="version pln"><em>(insert latest version)</em></span>&lt;/version>
&lt;/dependency></pre>
<h4>Gradle</h4>
<pre class="prettyprint">implementation 'com.squareup.okhttp3:okhttp:<span class="version pln"><em>(insert latest version)</em></span>'</pre>
<h3 id="contributing">Contributing</h3>
<p>If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.</p>
<p>When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Please also make sure your code compiles by running <code>./gradlew check</code>.</p>
<p>Some general advice</p>
<ul>
<li>Dont change public API lightly, avoid if possible, and include your reasoning in the PR if essential. It causes pain for developers who use OkHttp and sometimes runtime errors.</li>
<li>Favour a working external library if appropriate. There are many examples of OkHttp libraries that can sit on top or hook in via existing APIs.</li>
<li>Get working code on a personal branch with tests before you submit a PR.</li>
<li>OkHttp is a small and light dependency. Don't introduce new dependencies or major new functionality.</li>
<li>OkHttp targets the intersection of RFC correct and widely implemented. Incorrect implementations that are very widely implemented e.g. a bug in Apache, Nginx, Google, Firefox should also be handled.</li>
</ul>
<p>Before your code can be accepted into the project you must also sign the <a href="https://squ.re/sign-the-cla">Individual Contributor License Agreement (CLA)</a>.</p>
<h3 id="license">License</h3>
<pre>Copyright 2016 Square, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>
</div>
<div class="span3">
<div class="content-nav" data-spy="affix" data-offset-top="80">
<ul class="nav nav-tabs nav-stacked primary">
<li><a href="#overview">Overview</a></li>
<li><a href="#examples">Examples</a></li>
<li><a href="#download">Download</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
</ul>
<ul class="nav nav-pills nav-stacked secondary">
<li><a href="3.x/okhttp/">Javadoc</a></li>
<li><a href="https://stackoverflow.com/questions/tagged/okhttp?sort=active">StackOverflow</a></li>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="span12 logo">
<a href="https://squareup.com"><img src="static/logo-square.png" alt="Square, Inc."/></a>
</div>
</div>
</div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="static/bootstrap.min.js"></script>
<script src="static/jquery.smooth-scroll.min.js"></script>
<script src="static/jquery-maven-artifact.min.js"></script>
<script src="static/prettify.js"></script>
<script type="text/javascript">
$(function() {
// Syntax highlight code blocks.
prettyPrint();
// Spy on scroll position for real-time updating of current section.
$('body').scrollspy();
// Use smooth-scroll for internal links.
$('a').smoothScroll();
// Enable tooltips on the header nav image items.
$('.menu').tooltip({
placement: 'bottom',
trigger: 'hover',
container: 'body',
delay: {
show: 500,
hide: 0
}
});
// Look up the latest version of the library.
$.fn.artifactVersion({
'groupId': 'com.squareup.okhttp3',
'artifactId': 'okhttp'
}, function(version, url) {
$('.version').text(version);
$('.version-tag').text('v' + version);
$('.version-href').attr('href', url);
});
});
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-40704740-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>

View File

@@ -1,51 +0,0 @@
/* http://www.colorhexa.com/487fb9 */
/*** Primary ***/
header,
#subtitle,
a.dl {
background-color: #48b7b9;
}
.content-nav li.active a,
.content-nav li.active a:hover {
border-left-color: #48b7b9;
}
/*** One step left on the monochromatic scale ***/
header menu li a:hover,
a.dl:hover {
background-color: #40a6a7;
}
a {
color: #40a6a7;
}
/*** Three steps left on the monochromatic scale ***/
a:hover {
color: #328183;
}
/****************************************************************\
**** Syntax highlighting styles ********************************
\****************************************************************/
.pln { color: #000; }
.str { color: #399395; }
.kwd { color: #666; }
.com { color: #399395; }
.typ { color: #222; }
.lit { color: #666; }
.pun { color: #888; }
.opn { color: #888; }
.clo { color: #888; }
.tag { color: #399395; }
.atn { color: #606; }
.atv { color: #080; }
.dec { color: #606; }
.var { color: #606; }
.fun { color: #f00; }

View File

@@ -1,188 +0,0 @@
html, body {
font-family: 'Roboto', sans-serif;
font-size: 15px;
}
body {
background-color: #f6f6f6;
padding-bottom: 50px;
padding-top: 80px;
}
header {
min-height: 80px;
color: #f6f6f6;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
}
header h1 {
margin: 10px 0;
font-size: 50px;
line-height: 60px;
font-weight: 100;
text-rendering: auto;
}
header menu {
margin: 20px 0 0;
padding: 0;
height: 40px;
}
header menu ul {
margin: 0;
padding: 0;
float: right;
}
header menu li {
list-style: none;
float: left;
margin: 0;
padding: 0;
}
header menu li a {
display: inline-block;
height: 40px;
font-size: 17px;
line-height: 40px;
padding: 0 20px;
color: #f6f6f6;
}
header menu li a:hover {
color: #f6f6f6;
text-decoration: none;
}
header menu li a img {
margin: 0;
padding: 5px 0;
vertical-align: bottom;
width: 30px;
height: 30px;
}
#subtitle {
position: absolute;
top: 80px;
left: 0;
width: 100%;
}
h2 {
font-weight: 200;
font-size: 26px;
line-height: 30px;
padding: 15px 0;
margin: 0;
color: #eee;
}
h2 strong {
font-weight: 300;
}
a.dl {
font-weight: 300;
font-size: 30px;
line-height: 40px;
padding: 3px 10px;
display: inline-block;
border-radius: 6px;
color: #f0f0f0;
margin: 5px 0;
}
a.dl:hover {
color: #f0f0f0;
text-decoration: none;
}
.content-nav {
margin-top: 130px;
width: 220px;
}
.content-nav.affix {
top: 0;
}
.content-nav li.active a, .content-nav li.active a:hover {
background-color: transparent;
color: #555;
border-left-width: 2px;
}
.content-nav .secondary a {
color: #aaa;
}
.content-nav .secondary a:hover {
color: #888;
}
h3 {
font-weight: 300;
font-style: italic;
color: #888;
font-size: 20px;
padding-top: 115px;
margin-top: 0;
}
h4 {
font-weight: 400;
text-transform: uppercase;
color: #888;
font-size: 15px;
padding-top: 20px;
}
p.license {
font-family: fixed-width;
}
.row .logo {
text-align: center;
margin-top: 150px;
}
.row .logo img {
height: 30px;
}
pre, code {
color: #666;
}
code {
border: 0;
background-color: transparent;
}
/* Widescreen desktop. */
@media (min-width: 1200px) {
.content-nav {
width: 270px;
}
}
/* Smaller width browser, tablets. */
@media (max-width: 979px) {
.content-nav {
width: 166px;
}
}
/* One-column mobile display. */
@media (max-width: 767px) {
header {
position: absolute;
top: 0;
left: 0;
width: 100%;
padding-left: 20px;
}
header menu {
display: none;
}
#subtitle {
position: absolute;
top: 80px;
left: 0;
width: 100%;
padding-left: 20px;
}
.content-nav {
display: none;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +0,0 @@
/*
HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",version:"3.6.2pre",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment();
for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1,7 +0,0 @@
/**
* jQuery Maven Artifact Plugin
*
* Version: 2.0.0
* Author: Jake Wharton
* License: Apache 2.0
*/(function(e){function n(e,t){var n=e.groupId.replace(/\./g,"/"),r="https://repo1.maven.org/maven2/"+n+"/"+e.artifactId+"/"+t+"/"+e.artifactId+"-"+t;return typeof e.classifier!="undefined"&&(r+="-"+e.classifier),r+="."+e.packaging,r}function r(e){var t={groupId:"g",artifactId:"a",packaging:"p",classifier:"l"},n="";for(var r in t)t.hasOwnProperty(r)&&e.hasOwnProperty(r)&&(n!==""&&(n+="+AND+"),n+=t[r]+':"'+e[r]+'"');return n}var t={packaging:"jar"};e.fn.artifactVersion=function(i,s){if(typeof i=="undefined"){alert("Error: config object is required.");return}if(typeof s=="undefined"){alert("Error: callback function required.");return}var i=e.extend({},t,i),o="https://search.maven.org/solrsearch/select/?q="+r(i)+"&wt=json&json.wrf=?";e.getJSON(o,function(e){var t=e.response.docs;if(t.length==0)return;var r=t[0].latestVersion||t[0].v,o=n(i,r);s(r,o)})},e.fn.artifactVersions=function(i,s){if(typeof i=="undefined"){alert("Error: config object is required.");return}if(typeof s=="undefined"){alert("Error: callback function required.");return}var i=e.extend({},t,i),o="https://search.maven.org/solrsearch/select/?q="+r(i)+"&wt=json&rows=10&core=gav&json.wrf=?";e.getJSON(o,function(e){var t=e.response.docs;if(t.length==0)return;t.sort(function(e,t){return e.v>t.v?-1:1});var r=[];for(var o=0;o<t.length;o++){var u=t[o].v;r.push({name:u,url:n(i,u)})}s(r)})}})(jQuery);

View File

@@ -1,7 +0,0 @@
/*!
* Smooth Scroll - v1.4.10 - 2013-03-02
* https://github.com/kswedberg/jquery-smooth-scroll
* Copyright (c) 2013 Karl Swedberg
* Licensed MIT (https://github.com/kswedberg/jquery-smooth-scroll/blob/master/LICENSE-MIT)
*/
(function(l){function t(l){return l.replace(/(:|\.)/g,"\\$1")}var e="1.4.10",o={exclude:[],excludeWithin:[],offset:0,direction:"top",scrollElement:null,scrollTarget:null,beforeScroll:function(){},afterScroll:function(){},easing:"swing",speed:400,autoCoefficent:2},r=function(t){var e=[],o=!1,r=t.dir&&"left"==t.dir?"scrollLeft":"scrollTop";return this.each(function(){if(this!=document&&this!=window){var t=l(this);t[r]()>0?e.push(this):(t[r](1),o=t[r]()>0,o&&e.push(this),t[r](0))}}),e.length||this.each(function(){"BODY"===this.nodeName&&(e=[this])}),"first"===t.el&&e.length>1&&(e=[e[0]]),e};l.fn.extend({scrollable:function(l){var t=r.call(this,{dir:l});return this.pushStack(t)},firstScrollable:function(l){var t=r.call(this,{el:"first",dir:l});return this.pushStack(t)},smoothScroll:function(e){e=e||{};var o=l.extend({},l.fn.smoothScroll.defaults,e),r=l.smoothScroll.filterPath(location.pathname);return this.unbind("click.smoothscroll").bind("click.smoothscroll",function(e){var n=this,s=l(this),c=o.exclude,i=o.excludeWithin,a=0,f=0,h=!0,u={},d=location.hostname===n.hostname||!n.hostname,m=o.scrollTarget||(l.smoothScroll.filterPath(n.pathname)||r)===r,p=t(n.hash);if(o.scrollTarget||d&&m&&p){for(;h&&c.length>a;)s.is(t(c[a++]))&&(h=!1);for(;h&&i.length>f;)s.closest(i[f++]).length&&(h=!1)}else h=!1;h&&(e.preventDefault(),l.extend(u,o,{scrollTarget:o.scrollTarget||p,link:n}),l.smoothScroll(u))}),this}}),l.smoothScroll=function(t,e){var o,r,n,s,c=0,i="offset",a="scrollTop",f={},h={};"number"==typeof t?(o=l.fn.smoothScroll.defaults,n=t):(o=l.extend({},l.fn.smoothScroll.defaults,t||{}),o.scrollElement&&(i="position","static"==o.scrollElement.css("position")&&o.scrollElement.css("position","relative"))),o=l.extend({link:null},o),a="left"==o.direction?"scrollLeft":a,o.scrollElement?(r=o.scrollElement,c=r[a]()):r=l("html, body").firstScrollable(),o.beforeScroll.call(r,o),n="number"==typeof t?t:e||l(o.scrollTarget)[i]()&&l(o.scrollTarget)[i]()[o.direction]||0,f[a]=n+c+o.offset,s=o.speed,"auto"===s&&(s=f[a]||r.scrollTop(),s/=o.autoCoefficent),h={duration:s,easing:o.easing,complete:function(){o.afterScroll.call(o.link,o)}},o.step&&(h.step=o.step),r.length?r.stop().animate(f,h):o.afterScroll.call(o.link,o)},l.smoothScroll.version=e,l.smoothScroll.filterPath=function(l){return l.replace(/^\//,"").replace(/(index|default).[a-zA-Z]{3,4}$/,"").replace(/\/$/,"")},l.fn.smoothScroll.defaults=o})(jQuery);

View File

@@ -1,30 +0,0 @@
!function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a=
b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a<f;++a){var h=b[a];if(/\\[bdsw]/i.test(h))c.push(h);else{var h=d(h),l;a+2<f&&"-"===b[a+1]?(l=d(b[a+2]),a+=2):l=h;e.push([h,l]);l<65||h>122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;a<e.length;++a)h=e[a],h[0]<=f[1]+1?f[1]=Math.max(f[1],h[1]):b.push(f=h);for(a=0;a<b.length;++a)h=b[a],c.push(g(h[0])),
h[1]>h[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f<c;++f){var l=a[f];l==="("?++h:"\\"===l.charAt(0)&&(l=+l.substring(1))&&(l<=h?d[l]=-1:a[f]=g(l))}for(f=1;f<d.length;++f)-1===d[f]&&(d[f]=++x);for(h=f=0;f<c;++f)l=a[f],l==="("?(++h,d[h]||(a[f]="(?:")):"\\"===l.charAt(0)&&(l=+l.substring(1))&&l<=h&&
(a[f]="\\"+d[l]);for(f=0;f<c;++f)"^"===a[f]&&"^"!==a[f+1]&&(a[f]="");if(e.ignoreCase&&m)for(f=0;f<c;++f)l=a[f],e=l.charAt(0),l.length>=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k<c;++k){var i=a[k];if(i.ignoreCase)j=!0;else if(/[a-z]/i.test(i.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){m=!0;j=!1;break}}for(var r={b:8,t:9,n:10,v:11,
f:12,r:13},n=[],k=0,c=a.length;k<c;++k){i=a[k];if(i.global||i.multiline)throw Error(""+i);n.push("(?:"+s(i)+")")}return RegExp(n.join("|"),j?"gi":"g")}function T(a,d){function g(a){var c=a.nodeType;if(c==1){if(!b.test(a.className)){for(c=a.firstChild;c;c=c.nextSibling)g(c);c=a.nodeName.toLowerCase();if("br"===c||"li"===c)s[j]="\n",m[j<<1]=x++,m[j++<<1|1]=a}}else if(c==3||c==4)c=a.nodeValue,c.length&&(c=d?c.replace(/\r\n?/g,"\n"):c.replace(/[\t\n\r ]+/g," "),s[j]=c,m[j<<1]=x,x+=c.length,m[j++<<1|1]=
a)}var b=/(?:^|\s)nocode(?:\s|$)/,s=[],x=0,m=[],j=0;g(a);return{a:s.join("").replace(/\n$/,""),d:m}}function H(a,d,g,b){d&&(a={a:d,e:a},g(a),b.push.apply(b,a.g))}function U(a){for(var d=void 0,g=a.firstChild;g;g=g.nextSibling)var b=g.nodeType,d=b===1?d?a:g:b===3?V.test(g.nodeValue)?a:d:d;return d===a?void 0:d}function C(a,d){function g(a){for(var j=a.e,k=[j,"pln"],c=0,i=a.a.match(s)||[],r={},n=0,e=i.length;n<e;++n){var z=i[n],w=r[z],t=void 0,f;if(typeof w==="string")f=!1;else{var h=b[z.charAt(0)];
if(h)t=z.match(h[1]),w=h[0];else{for(f=0;f<x;++f)if(h=d[f],t=z.match(h[1])){w=h[0];break}t||(w="pln")}if((f=w.length>=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c<i;++c){var r=
g[c],n=r[3];if(n)for(var e=n.length;--e>=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com",
/^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+
s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,
q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d=
c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i<c.length;++i)b(c[i]);d===(d|0)&&c[0].setAttribute("value",d);var r=j.createElement("ol");
r.className="linenums";for(var d=Math.max(0,d-1|0)||0,i=0,n=c.length;i<n;++i)k=c[i],k.className="L"+(i+d)%10,k.firstChild||k.appendChild(j.createTextNode("\u00a0")),r.appendChild(k);a.appendChild(r)}function p(a,d){for(var g=d.length;--g>=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*</.test(d)?"default-markup":"default-code";return F[a]}function K(a){var d=a.h;try{var g=T(a.c,a.i),b=g.a;
a.a=b;a.d=g.d;a.e=0;I(d,b)(a);var s=/\bMSIE\s(\d+)/.exec(navigator.userAgent),s=s&&+s[1]<=8,d=/\n/g,x=a.a,m=x.length,g=0,j=a.d,k=j.length,b=0,c=a.g,i=c.length,r=0;c[i]=m;var n,e;for(e=n=0;e<i;)c[e]!==c[e+2]?(c[n++]=c[e++],c[n++]=c[e++]):e+=2;i=n;for(e=n=0;e<i;){for(var p=c[e],w=c[e+1],t=e+2;t+2<=i&&c[t+1]===w;)t+=2;c[n++]=p;c[n++]=w;e=t}c.length=n;var f=a.c,h;if(f)h=f.style.display,f.style.display="none";try{for(;b<k;){var l=j[b+2]||m,B=c[r+2]||m,t=Math.min(l,B),A=j[b+1],G;if(A.nodeType!==1&&(G=x.substring(g,
t))){s&&(G=G.replace(d,"\r"));A.nodeValue=G;var L=A.ownerDocument,o=L.createElement("span");o.className=c[r+1];var v=A.parentNode;v.replaceChild(o,A);o.appendChild(A);g<l&&(j[b+1]=A=L.createTextNode(x.substring(t,l)),v.insertBefore(A,o.nextSibling))}g=t;g>=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],
O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,
V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",
/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);p(C([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],
["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);p(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);p(v({keywords:M,hashComments:!0,cStyleComments:!0,types:R}),["c","cc","cpp","cxx","cyc","m"]);p(v({keywords:"null,true,false"}),["json"]);p(v({keywords:O,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:R}),
["cs"]);p(v({keywords:N,cStyleComments:!0}),["java"]);p(v({keywords:y,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);p(v({keywords:P,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);p(v({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);p(v({keywords:Q,
hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);p(v({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);p(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);p(v({keywords:W,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]);
p(C([],[["str",/^[\S\s]+/]]),["regex"]);var Y=D.PR={createSimpleLexer:C,registerLangHandler:p,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:D.prettyPrintOne=function(a,d,g){var b=document.createElement("div");b.innerHTML="<pre>"+a+"</pre>";b=b.firstChild;g&&J(b,g,!0);K({h:d,j:g,c:b,i:1});
return b.innerHTML},prettyPrint:D.prettyPrint=function(a,d){function g(){for(var b=D.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;i<p.length&&c.now()<b;i++){for(var d=p[i],j=h,k=d;k=k.previousSibling;){var m=k.nodeType,o=(m===7||m===8)&&k.nodeValue;if(o?!/^\??prettify\b/.test(o):m!==3||/\S/.test(k.nodeValue))break;if(o){j={};o.replace(/\b(\w+)=([\w%+\-.:]+)/g,function(a,b,c){j[b]=c});break}}k=d.className;if((j!==h||e.test(k))&&!v.test(k)){m=!1;for(o=d.parentNode;o;o=o.parentNode)if(f.test(o.tagName)&&
o.className&&e.test(o.className)){m=!0;break}if(!m){d.className+=" prettyprinted";m=j.lang;if(!m){var m=k.match(n),y;if(!m&&(y=U(d))&&t.test(y.tagName))m=y.className.match(n);m&&(m=m[1])}if(w.test(d.tagName))o=1;else var o=d.currentStyle,u=s.defaultView,o=(o=o?o.whiteSpace:u&&u.getComputedStyle?u.getComputedStyle(d,q).getPropertyValue("white-space"):0)&&"pre"===o.substring(0,3);u=j.linenums;if(!(u=u==="true"||+u))u=(u=k.match(/\blinenums\b(?::(\d+))?/))?u[1]&&u[1].length?+u[1]:!0:!1;u&&J(d,u,o);r=
{h:m,c:d,j:u,i:o};K(r)}}}i<p.length?setTimeout(g,250):"function"===typeof a&&a()}for(var b=d||document.body,s=b.ownerDocument||document,b=[b.getElementsByTagName("pre"),b.getElementsByTagName("code"),b.getElementsByTagName("xmp")],p=[],m=0;m<b.length;++m)for(var j=0,k=b[m].length;j<k;++j)p.push(b[m][j]);var b=q,c=Date;c.now||(c={now:function(){return+new Date}});var i=0,r,n=/\blang(?:uage)?-([\w.]+)(?!\S)/,e=/\bprettyprint\b/,v=/\bprettyprinted\b/,w=/pre|xmp/i,t=/^code$/i,f=/^(?:pre|code|xmp)$/i,
h={};g()}};typeof define==="function"&&define.amd&&define("google-code-prettify",[],function(){return Y})})();}()