Showing preview only (842K chars total). Download the full file or copy to clipboard to get everything.
Repository: koush/AndroidAsync
Branch: master
Commit: 12f9e20443db
Files: 244
Total size: 769.9 KB
Directory structure:
gitextract_o_k792rl/
├── .github/
│ └── FUNDING.yml
├── .gitignore
├── AndroidAsync/
│ ├── .classpath
│ ├── Android.mk
│ ├── AndroidManifest.xml
│ ├── build.gradle
│ ├── lint.xml
│ ├── maven.gradle
│ ├── proguard-project.txt
│ ├── project.properties
│ ├── res/
│ │ └── .gitignore
│ ├── src/
│ │ └── com/
│ │ └── koushikdutta/
│ │ └── async/
│ │ ├── AsyncDatagramSocket.java
│ │ ├── AsyncNetworkSocket.java
│ │ ├── AsyncSSLException.java
│ │ ├── AsyncSSLServerSocket.java
│ │ ├── AsyncSSLSocket.java
│ │ ├── AsyncSSLSocketWrapper.java
│ │ ├── AsyncSemaphore.java
│ │ ├── AsyncServer.java
│ │ ├── AsyncServerSocket.java
│ │ ├── AsyncSocket.java
│ │ ├── BufferedDataSink.java
│ │ ├── ByteBufferList.java
│ │ ├── ChannelWrapper.java
│ │ ├── DataEmitter.java
│ │ ├── DataEmitterBase.java
│ │ ├── DataEmitterReader.java
│ │ ├── DataSink.java
│ │ ├── DataTrackingEmitter.java
│ │ ├── DatagramChannelWrapper.java
│ │ ├── FileDataEmitter.java
│ │ ├── FilteredDataEmitter.java
│ │ ├── FilteredDataSink.java
│ │ ├── HostnameResolutionException.java
│ │ ├── LineEmitter.java
│ │ ├── PushParser.java
│ │ ├── SelectorWrapper.java
│ │ ├── ServerSocketChannelWrapper.java
│ │ ├── SocketChannelWrapper.java
│ │ ├── TapCallback.java
│ │ ├── ThreadQueue.java
│ │ ├── Util.java
│ │ ├── ZipDataSink.java
│ │ ├── callback/
│ │ │ ├── CompletedCallback.java
│ │ │ ├── ConnectCallback.java
│ │ │ ├── ContinuationCallback.java
│ │ │ ├── DataCallback.java
│ │ │ ├── ListenCallback.java
│ │ │ ├── ResultCallback.java
│ │ │ ├── SocketCreateCallback.java
│ │ │ ├── ValueCallback.java
│ │ │ ├── ValueFunction.java
│ │ │ └── WritableCallback.java
│ │ ├── dns/
│ │ │ ├── Dns.java
│ │ │ └── DnsResponse.java
│ │ ├── future/
│ │ │ ├── Cancellable.java
│ │ │ ├── Continuation.java
│ │ │ ├── Converter.java
│ │ │ ├── DependentCancellable.java
│ │ │ ├── DependentFuture.java
│ │ │ ├── DoneCallback.java
│ │ │ ├── FailCallback.java
│ │ │ ├── FailConvertCallback.java
│ │ │ ├── FailRecoverCallback.java
│ │ │ ├── Future.java
│ │ │ ├── FutureCallback.java
│ │ │ ├── FutureRunnable.java
│ │ │ ├── FutureThread.java
│ │ │ ├── Futures.java
│ │ │ ├── HandlerFuture.java
│ │ │ ├── MultiFuture.java
│ │ │ ├── MultiTransformFuture.java
│ │ │ ├── SimpleCancellable.java
│ │ │ ├── SimpleFuture.java
│ │ │ ├── SuccessCallback.java
│ │ │ ├── ThenCallback.java
│ │ │ ├── ThenFutureCallback.java
│ │ │ ├── TransformFuture.java
│ │ │ └── TypeConverter.java
│ │ ├── http/
│ │ │ ├── AsyncHttpClient.java
│ │ │ ├── AsyncHttpClientMiddleware.java
│ │ │ ├── AsyncHttpDelete.java
│ │ │ ├── AsyncHttpGet.java
│ │ │ ├── AsyncHttpHead.java
│ │ │ ├── AsyncHttpPost.java
│ │ │ ├── AsyncHttpPut.java
│ │ │ ├── AsyncHttpRequest.java
│ │ │ ├── AsyncHttpResponse.java
│ │ │ ├── AsyncHttpResponseImpl.java
│ │ │ ├── AsyncSSLEngineConfigurator.java
│ │ │ ├── AsyncSSLSocketMiddleware.java
│ │ │ ├── AsyncSocketMiddleware.java
│ │ │ ├── BasicNameValuePair.java
│ │ │ ├── BodyDecoderException.java
│ │ │ ├── ConnectionClosedException.java
│ │ │ ├── ConnectionFailedException.java
│ │ │ ├── Headers.java
│ │ │ ├── HttpDate.java
│ │ │ ├── HttpTransportMiddleware.java
│ │ │ ├── HttpUtil.java
│ │ │ ├── HybiParser.java
│ │ │ ├── Multimap.java
│ │ │ ├── NameValuePair.java
│ │ │ ├── Protocol.java
│ │ │ ├── ProtocolVersion.java
│ │ │ ├── RedirectLimitExceededException.java
│ │ │ ├── RequestLine.java
│ │ │ ├── SSLEngineSNIConfigurator.java
│ │ │ ├── SimpleMiddleware.java
│ │ │ ├── WebSocket.java
│ │ │ ├── WebSocketHandshakeException.java
│ │ │ ├── WebSocketImpl.java
│ │ │ ├── body/
│ │ │ │ ├── AsyncHttpRequestBody.java
│ │ │ │ ├── ByteBufferListRequestBody.java
│ │ │ │ ├── DocumentBody.java
│ │ │ │ ├── FileBody.java
│ │ │ │ ├── FilePart.java
│ │ │ │ ├── JSONArrayBody.java
│ │ │ │ ├── JSONObjectBody.java
│ │ │ │ ├── MultipartFormDataBody.java
│ │ │ │ ├── Part.java
│ │ │ │ ├── StreamBody.java
│ │ │ │ ├── StreamPart.java
│ │ │ │ ├── StringBody.java
│ │ │ │ ├── StringPart.java
│ │ │ │ └── UrlEncodedFormBody.java
│ │ │ ├── cache/
│ │ │ │ ├── HeaderParser.java
│ │ │ │ ├── Objects.java
│ │ │ │ ├── RawHeaders.java
│ │ │ │ ├── RequestHeaders.java
│ │ │ │ ├── ResponseCacheMiddleware.java
│ │ │ │ ├── ResponseHeaders.java
│ │ │ │ ├── ResponseSource.java
│ │ │ │ └── StrictLineReader.java
│ │ │ ├── callback/
│ │ │ │ ├── HttpConnectCallback.java
│ │ │ │ └── RequestCallback.java
│ │ │ ├── filter/
│ │ │ │ ├── ChunkedDataException.java
│ │ │ │ ├── ChunkedInputFilter.java
│ │ │ │ ├── ChunkedOutputFilter.java
│ │ │ │ ├── ContentLengthFilter.java
│ │ │ │ ├── DataRemainingException.java
│ │ │ │ ├── GZIPInputFilter.java
│ │ │ │ ├── InflaterInputFilter.java
│ │ │ │ └── PrematureDataEndException.java
│ │ │ └── server/
│ │ │ ├── AsyncHttpRequestBodyProvider.java
│ │ │ ├── AsyncHttpServer.java
│ │ │ ├── AsyncHttpServerRequest.java
│ │ │ ├── AsyncHttpServerRequestImpl.java
│ │ │ ├── AsyncHttpServerResponse.java
│ │ │ ├── AsyncHttpServerResponseImpl.java
│ │ │ ├── AsyncHttpServerRouter.java
│ │ │ ├── AsyncProxyServer.java
│ │ │ ├── BoundaryEmitter.java
│ │ │ ├── HttpServerRequestCallback.java
│ │ │ ├── MalformedRangeException.java
│ │ │ ├── MimeEncodingException.java
│ │ │ ├── RouteMatcher.java
│ │ │ ├── StreamSkipException.java
│ │ │ └── UnknownRequestBody.java
│ │ ├── parser/
│ │ │ ├── AsyncParser.java
│ │ │ ├── ByteBufferListParser.java
│ │ │ ├── DocumentParser.java
│ │ │ ├── JSONArrayParser.java
│ │ │ ├── JSONObjectParser.java
│ │ │ └── StringParser.java
│ │ ├── stream/
│ │ │ ├── ByteBufferListInputStream.java
│ │ │ ├── FileDataSink.java
│ │ │ ├── InputStreamDataEmitter.java
│ │ │ ├── OutputStreamDataCallback.java
│ │ │ └── OutputStreamDataSink.java
│ │ ├── util/
│ │ │ ├── Allocator.java
│ │ │ ├── ArrayDeque.java
│ │ │ ├── Charsets.java
│ │ │ ├── Deque.java
│ │ │ ├── FileCache.java
│ │ │ ├── FileUtility.java
│ │ │ ├── HashList.java
│ │ │ ├── IdleTimeout.java
│ │ │ ├── LruCache.java
│ │ │ ├── StreamUtility.java
│ │ │ ├── TaggedList.java
│ │ │ ├── ThrottleTimeout.java
│ │ │ ├── TimeoutBase.java
│ │ │ └── UntypedHashtable.java
│ │ └── wrapper/
│ │ ├── AsyncSocketWrapper.java
│ │ └── DataEmitterWrapper.java
│ └── test/
│ ├── assets/
│ │ ├── 6691924d7d24237d3b3679310157d640
│ │ ├── hello.txt
│ │ └── test.json
│ ├── res/
│ │ ├── raw/
│ │ │ └── keystore.bks
│ │ └── values/
│ │ └── strings.xml
│ └── src/
│ └── com/
│ └── koushikdutta/
│ └── async/
│ └── test/
│ ├── BodyTests.java
│ ├── ByteUtilTests.java
│ ├── CacheTests.java
│ ├── CallbackTests.java
│ ├── ConscryptTests.java
│ ├── ConvertTests.java
│ ├── DnsTests.java
│ ├── FileCacheTests.java
│ ├── FileTests.java
│ ├── FutureTests.java
│ ├── HttpClientTests.java
│ ├── HttpServerTests.java
│ ├── Issue59.java
│ ├── IssueWithWebSocketFuturesTests.java
│ ├── LineEmitterTests.java
│ ├── Md5.java
│ ├── MultipartTests.java
│ ├── ParserTests.java
│ ├── ProxyTests.java
│ ├── RedirectTests.java
│ ├── SSLTests.java
│ ├── SanityChecks.java
│ ├── TimeoutTests.java
│ ├── TriggerFuture.java
│ └── WebSocketTests.java
├── AndroidAsync-Kotlin/
│ ├── .gitignore
│ ├── README.md
│ ├── build.gradle
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── koushikdutta/
│ │ └── async/
│ │ └── kotlin/
│ │ └── ExampleInstrumentedTest.kt
│ ├── main/
│ │ ├── AndroidManifest.xml
│ │ └── java/
│ │ └── com/
│ │ └── koushikdutta/
│ │ └── async/
│ │ └── kotlin/
│ │ └── FutureExtensions.kt
│ └── test/
│ └── java/
│ └── com/
│ └── koushikdutta/
│ └── async/
│ └── kotlin/
│ └── ExampleUnitTest.kt
├── AndroidAsyncSample/
│ ├── AndroidManifest.xml
│ ├── build.gradle
│ ├── proguard-project.txt
│ ├── project.properties
│ ├── res/
│ │ ├── layout/
│ │ │ └── activity_main.xml
│ │ ├── menu/
│ │ │ └── activity_main.xml
│ │ ├── values/
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ ├── values-v11/
│ │ │ └── styles.xml
│ │ └── values-v14/
│ │ └── styles.xml
│ └── src/
│ └── com/
│ └── koushikdutta/
│ └── async/
│ └── sample/
│ ├── MainActivity.java
│ └── middleware/
│ ├── BasicAuthMiddleware.java
│ └── CacheOverrideMiddleware.java
├── LICENSE
├── README.md
├── build.gradle
├── gradlew
├── gradlew.bat
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
github: koush
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
================================================
FILE: .gitignore
================================================
bin
.settings
local.properties
gen
.gradle
build
.idea/
.DS_Store
okhttp/
okio/
libs
*.iml
================================================
FILE: AndroidAsync/.classpath
================================================
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
================================================
FILE: AndroidAsync/Android.mk
================================================
#
# Copyright (C) 2011 The Android Open Source Project
#
# 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.
#
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := AndroidAsync
LOCAL_SDK_VERSION := 8
LOCAL_SRC_FILES := $(call all-java-files-under, src)
include $(BUILD_STATIC_JAVA_LIBRARY)
================================================
FILE: AndroidAsync/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.koushikdutta.async"
android:versionCode="310"
android:versionName="3.1.0">
<uses-permission android:name="android.permission.INTERNET"/>
<application>
</application>
</manifest>
================================================
FILE: AndroidAsync/build.gradle
================================================
apply plugin: 'com.android.library'
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
jniLibs.srcDirs = ['libs/']
java.srcDirs=['src/'
// , '../conscrypt/'
// , '../compat/'
]
}
androidTest.java.srcDirs=['test/src/']
androidTest.res.srcDirs=['test/res/']
androidTest.assets.srcDirs=['test/assets/']
}
lintOptions {
abortOnError false
}
defaultConfig {
targetSdkVersion 30
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
compileSdkVersion 30
buildToolsVersion '30.0.2'
dependencies {
// this is only necessary to get compilation working for self signed certificates. dependency isn't added.
compileOnly group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.60'
compileOnly group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.60'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// for when i wanna test this against gms conscrypt
androidTestImplementation 'com.google.android.gms:play-services-base:17.0.0'
}
}
apply from: 'maven.gradle'
================================================
FILE: AndroidAsync/lint.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>
================================================
FILE: AndroidAsync/maven.gradle
================================================
// Setup
// 0) Setup your sonatype credentials by editing/creating ~/.gradle/gradle.properties and enter:
// signing.keyId=<HEXADECIMCAL KEY ID RETRIVABLE VIA gpg --list-keys>
// signing.password=<KEY PASSWORD>
// signing.secretKeyRingFile=<PATH TO KEY RING, USUALLY ~/.gnupg/secring.gpg>
// sonatypeUsername=<SONATYPE USERNAME OR WHATEVER YOU USE>
// sonatypePassword=<CORRESPONDING PASSWORD>
// 1) Setup your build.gradle for your android project and add this one line of code which imports this gist:
// apply from: 'https://raw.github.com/koush/mvn-repo/master/maven.gradle'
// 2) gradle clean && gradle build && gradle uploadArchives
// 3) That's it!
apply plugin: 'maven'
apply plugin: 'signing'
if (hasProperty('sonatypeUsername') && hasProperty('sonatypePassword') && hasProperty('githubToken')) {
afterEvaluate { project ->
String user = null
String repo = null
'git remote -v'.execute(null, project.projectDir).getText().find('.*?git@github.com/(.*?)/(.*?) .*?') {
match ->
user = match[1]
repo = match[2]
}
String githubUrl = 'https://api.github.com/repos/' + user + '/' + repo
if (System.getenv().GITHUB_TOKEN)
githubUrl += '?access_token=' + System.getenv().GITHUB_TOKEN
def repoInfo = new groovy.json.JsonSlurper().parseText(new URL(githubUrl).getText())
def android_manifest
try {
android_manifest = new XmlParser(false, false).parseText(new File(project.projectDir, 'AndroidManifest.xml').getText())
}
catch (e) {
android_manifest = new XmlParser(false, false).parseText(new File(project.projectDir, 'src/main/AndroidManifest.xml').getText())
}
def versionName = android_manifest.'@android:versionName'
def package_name = android_manifest.'@package'
def artifact_id = project.projectDir.getName().toLowerCase()
project.version = versionName
project.group = package_name
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = package_name
pom.artifactId = artifact_id
pom.version = versionName
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.project {
name repo
packaging 'jar'
description repoInfo.description
url repoInfo.html_url
scm {
url repoInfo.git_url
connection repoInfo.git_url
developerConnection repoInfo.ssh_url
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id user
name user
}
}
}
}
}
}
signing {
sign configurations.archives
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
}
task androidJavadocsJar(type: Jar) {
classifier = 'javadoc'
baseName = artifact_id
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
baseName = artifact_id
from android.sourceSets.main.java.srcDirs
}
artifacts {
// archives packageReleaseJar
archives androidSourcesJar
archives androidJavadocsJar
}
}
}
================================================
FILE: AndroidAsync/proguard-project.txt
================================================
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class * extends com.koushikdutta.async.TapCallback {
public protected private *;
}
================================================
FILE: AndroidAsync/project.properties
================================================
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19
android.library=true
================================================
FILE: AndroidAsync/res/.gitignore
================================================
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncDatagramSocket.java
================================================
package com.koushikdutta.async;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
public class AsyncDatagramSocket extends AsyncNetworkSocket {
public void disconnect() throws IOException {
socketAddress = null;
((DatagramChannelWrapper)getChannel()).disconnect();
}
@Override
public InetSocketAddress getRemoteAddress() {
if (isOpen())
return super.getRemoteAddress();
return ((DatagramChannelWrapper)getChannel()).getRemoteAddress();
}
public void connect(InetSocketAddress address) throws IOException {
socketAddress = address;
((DatagramChannelWrapper)getChannel()).mChannel.connect(address);
}
public void send(final String host, final int port, final ByteBuffer buffer) {
if (getServer().getAffinity() != Thread.currentThread()) {
getServer().run(new Runnable() {
@Override
public void run() {
send(host, port, buffer);
}
});
return;
}
try {
((DatagramChannelWrapper)getChannel()).mChannel.send(buffer, new InetSocketAddress(host, port));
}
catch (IOException e) {
// close();
// reportEndPending(e);
// reportClose(e);
}
}
public void send(final InetSocketAddress address, final ByteBuffer buffer) {
if (getServer().getAffinity() != Thread.currentThread()) {
getServer().run(new Runnable() {
@Override
public void run() {
send(address, buffer);
}
});
return;
}
try {
int sent = ((DatagramChannelWrapper)getChannel()).mChannel.send(buffer, new InetSocketAddress(address.getHostName(), address.getPort()));
}
catch (IOException e) {
// Log.e("SEND", "send error", e);
// close();
// reportEndPending(e);
// reportClose(e);
}
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java
================================================
package com.koushikdutta.async;
import android.util.Log;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.DataCallback;
import com.koushikdutta.async.callback.WritableCallback;
import com.koushikdutta.async.util.Allocator;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
public class AsyncNetworkSocket implements AsyncSocket {
AsyncNetworkSocket() {
}
@Override
public void end() {
mChannel.shutdownOutput();
}
public boolean isChunked() {
return mChannel.isChunked();
}
InetSocketAddress socketAddress;
void attach(SocketChannel channel, InetSocketAddress socketAddress) throws IOException {
this.socketAddress = socketAddress;
allocator = new Allocator();
mChannel = new SocketChannelWrapper(channel);
}
void attach(DatagramChannel channel) throws IOException {
mChannel = new DatagramChannelWrapper(channel);
// keep udp at roughly the mtu, which is 1540 or something
// letting it grow freaks out nio apparently.
allocator = new Allocator(8192);
}
ChannelWrapper getChannel() {
return mChannel;
}
public void onDataWritable() {
if (!mChannel.isChunked()) {
// turn write off
mKey.interestOps(~SelectionKey.OP_WRITE & mKey.interestOps());
}
if (mWriteableHandler != null)
mWriteableHandler.onWriteable();
}
private ChannelWrapper mChannel;
private SelectionKey mKey;
private AsyncServer mServer;
void setup(AsyncServer server, SelectionKey key) {
mServer = server;
mKey = key;
}
@Override
public void write(final ByteBufferList list) {
if (mServer.getAffinity() != Thread.currentThread()) {
mServer.run(new Runnable() {
@Override
public void run() {
write(list);
}
});
return;
}
if (!mChannel.isConnected()) {
return;
}
try {
int before = list.remaining();
ByteBuffer[] arr = list.getAllArray();
mChannel.write(arr);
list.addAll(arr);
handleRemaining(list.remaining());
mServer.onDataSent(before - list.remaining());
}
catch (IOException e) {
closeInternal();
reportEndPending(e);
reportClose(e);
}
}
private void handleRemaining(int remaining) throws IOException {
if (!mKey.isValid())
throw new IOException(new CancelledKeyException());
if (remaining > 0) {
// chunked channels should not fail
// register for a write notification if a write fails
// turn write on
mKey.interestOps(SelectionKey.OP_WRITE | mKey.interestOps());
}
else {
// turn write off
mKey.interestOps(~SelectionKey.OP_WRITE & mKey.interestOps());
}
}
private ByteBufferList pending = new ByteBufferList();
// private ByteBuffer[] buffers = new ByteBuffer[8];
Allocator allocator;
int onReadable() {
spitPending();
// even if the socket is paused,
// it may end up getting a queued readable event if it is
// already in the selector's ready queue.
if (mPaused)
return 0;
int total = 0;
boolean closed = false;
// ByteBufferList.obtainArray(buffers, Math.min(Math.max(mToAlloc, 2 << 11), maxAlloc));
ByteBuffer b = allocator.allocate();
// keep track of the max mount read during this read cycle
// so we can be quicker about allocations during the next
// time this socket reads.
long read;
try {
read = mChannel.read(b);
}
catch (Exception e) {
read = -1;
closeInternal();
reportEndPending(e);
reportClose(e);
}
if (read < 0) {
closeInternal();
closed = true;
}
else {
total += read;
}
if (read > 0) {
allocator.track(read);
b.flip();
// for (int i = 0; i < buffers.length; i++) {
// ByteBuffer b = buffers[i];
// buffers[i] = null;
// b.flip();
// pending.add(b);
// }
pending.add(b);
Util.emitAllData(this, pending);
}
else {
ByteBufferList.reclaim(b);
}
if (closed) {
reportEndPending(null);
reportClose(null);
}
return total;
}
boolean closeReported;
protected void reportClose(Exception e) {
if (closeReported)
return;
closeReported = true;
if (mClosedHander != null) {
mClosedHander.onCompleted(e);
mClosedHander = null;
}
}
@Override
public void close() {
closeInternal();
reportClose(null);
}
private void closeInternal() {
mKey.cancel();
try {
mChannel.close();
}
catch (IOException e) {
}
}
WritableCallback mWriteableHandler;
@Override
public void setWriteableCallback(WritableCallback handler) {
mWriteableHandler = handler;
}
DataCallback mDataHandler;
@Override
public void setDataCallback(DataCallback callback) {
mDataHandler = callback;
}
@Override
public DataCallback getDataCallback() {
return mDataHandler;
}
CompletedCallback mClosedHander;
@Override
public void setClosedCallback(CompletedCallback handler) {
mClosedHander = handler;
}
@Override
public CompletedCallback getClosedCallback() {
return mClosedHander;
}
@Override
public WritableCallback getWriteableCallback() {
return mWriteableHandler;
}
void reportEnd(Exception e) {
if (mEndReported)
return;
mEndReported = true;
if (mCompletedCallback != null)
mCompletedCallback.onCompleted(e);
else if (e != null) {
Log.e("NIO", "Unhandled exception", e);
}
}
boolean mEndReported;
Exception mPendingEndException;
void reportEndPending(Exception e) {
if (pending.hasRemaining()) {
mPendingEndException = e;
return;
}
reportEnd(e);
}
private CompletedCallback mCompletedCallback;
@Override
public void setEndCallback(CompletedCallback callback) {
mCompletedCallback = callback;
}
@Override
public CompletedCallback getEndCallback() {
return mCompletedCallback;
}
@Override
public boolean isOpen() {
return mChannel.isConnected() && mKey.isValid();
}
boolean mPaused = false;
@Override
public void pause() {
if (mServer.getAffinity() != Thread.currentThread()) {
mServer.run(new Runnable() {
@Override
public void run() {
pause();
}
});
return;
}
if (mPaused)
return;
mPaused = true;
try {
mKey.interestOps(~SelectionKey.OP_READ & mKey.interestOps());
}
catch (Exception ex) {
}
}
private void spitPending() {
if (pending.hasRemaining()) {
Util.emitAllData(this, pending);
}
}
@Override
public void resume() {
if (mServer.getAffinity() != Thread.currentThread()) {
mServer.run(new Runnable() {
@Override
public void run() {
resume();
}
});
return;
}
if (!mPaused)
return;
mPaused = false;
try {
mKey.interestOps(SelectionKey.OP_READ | mKey.interestOps());
}
catch (Exception ex) {
}
spitPending();
if (!isOpen())
reportEndPending(mPendingEndException);
}
@Override
public boolean isPaused() {
return mPaused;
}
@Override
public AsyncServer getServer() {
return mServer;
}
public InetSocketAddress getRemoteAddress() {
return socketAddress;
}
public InetAddress getLocalAddress() {
return mChannel.getLocalAddress();
}
public int getLocalPort() {
return mChannel.getLocalPort();
}
public Object getSocket() {
return getChannel().getSocket();
}
@Override
public String charset() {
return null;
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLException.java
================================================
package com.koushikdutta.async;
public class AsyncSSLException extends Exception {
public AsyncSSLException(Throwable cause) {
super("Peer not trusted by any of the system trust managers.", cause);
}
private boolean mIgnore = false;
public void setIgnore(boolean ignore) {
mIgnore = ignore;
}
public boolean getIgnore() {
return mIgnore;
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLServerSocket.java
================================================
package com.koushikdutta.async;
import java.security.PrivateKey;
import java.security.cert.Certificate;
public interface AsyncSSLServerSocket extends AsyncServerSocket {
PrivateKey getPrivateKey();
Certificate getCertificate();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocket.java
================================================
package com.koushikdutta.async;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLEngine;
public interface AsyncSSLSocket extends AsyncSocket {
public X509Certificate[] getPeerCertificates();
public SSLEngine getSSLEngine();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocketWrapper.java
================================================
package com.koushikdutta.async;
import android.content.Context;
import android.os.Build;
import android.util.Base64;
import android.util.Log;
import android.util.Pair;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.ConnectCallback;
import com.koushikdutta.async.callback.DataCallback;
import com.koushikdutta.async.callback.ListenCallback;
import com.koushikdutta.async.callback.WritableCallback;
import com.koushikdutta.async.future.Cancellable;
import com.koushikdutta.async.future.SimpleCancellable;
import com.koushikdutta.async.http.SSLEngineSNIConfigurator;
import com.koushikdutta.async.util.Allocator;
import com.koushikdutta.async.util.StreamUtility;
import com.koushikdutta.async.wrapper.AsyncSocketWrapper;
import org.apache.http.conn.ssl.StrictHostnameVerifier;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Calendar;
import java.util.Date;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
import javax.net.ssl.SSLEngineResult.Status;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
public class AsyncSSLSocketWrapper implements AsyncSocketWrapper, AsyncSSLSocket {
private static final String LOGTAG = "AsyncSSLSocketWrapper";
public interface HandshakeCallback {
public void onHandshakeCompleted(Exception e, AsyncSSLSocket socket);
}
static SSLContext defaultSSLContext;
static SSLContext trustAllSSLContext;
static TrustManager[] trustAllManagers;
static HostnameVerifier trustAllVerifier;
AsyncSocket mSocket;
BufferedDataSink mSink;
boolean mUnwrapping;
SSLEngine engine;
boolean finishedHandshake;
private int mPort;
private String mHost;
private boolean mWrapping;
HostnameVerifier hostnameVerifier;
HandshakeCallback handshakeCallback;
X509Certificate[] peerCertificates;
WritableCallback mWriteableCallback;
DataCallback mDataCallback;
TrustManager[] trustManagers;
boolean clientMode;
static {
// following is the "trust the system" certs setup
try {
// critical extension 2.5.29.15 is implemented improperly prior to 4.0.3.
// https://code.google.com/p/android/issues/detail?id=9307
// https://groups.google.com/forum/?fromgroups=#!topic/netty/UCfqPPk5O4s
// certs that use this extension will throw in Cipher.java.
// fallback is to use a custom SSLContext, and hack around the x509 extension.
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
throw new Exception();
defaultSSLContext = SSLContext.getInstance("Default");
}
catch (Exception ex) {
try {
defaultSSLContext = SSLContext.getInstance("TLS");
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
for (X509Certificate cert : certs) {
if (cert != null && cert.getCriticalExtensionOIDs() != null)
cert.getCriticalExtensionOIDs().remove("2.5.29.15");
}
}
} };
defaultSSLContext.init(null, trustAllCerts, null);
}
catch (Exception ex2) {
ex.printStackTrace();
ex2.printStackTrace();
}
}
try {
trustAllSSLContext = SSLContext.getInstance("TLS");
trustAllManagers = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
} };
trustAllSSLContext.init(null, trustAllManagers, null);
trustAllVerifier = (hostname, session) -> true;
}
catch (Exception ex2) {
ex2.printStackTrace();
}
}
public static SSLContext getDefaultSSLContext() {
return defaultSSLContext;
}
public static void handshake(AsyncSocket socket,
String host, int port,
SSLEngine sslEngine,
TrustManager[] trustManagers, HostnameVerifier verifier, boolean clientMode,
final HandshakeCallback callback) {
AsyncSSLSocketWrapper wrapper = new AsyncSSLSocketWrapper(socket, host, port, sslEngine, trustManagers, verifier, clientMode);
wrapper.handshakeCallback = callback;
socket.setClosedCallback(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
if (ex != null)
callback.onHandshakeCompleted(ex, null);
else
callback.onHandshakeCompleted(new SSLException("socket closed during handshake"), null);
}
});
try {
wrapper.engine.beginHandshake();
wrapper.handleHandshakeStatus(wrapper.engine.getHandshakeStatus());
} catch (SSLException e) {
wrapper.report(e);
}
}
public static Cancellable connectSocket(AsyncServer server, String host, int port, ConnectCallback callback) {
return connectSocket(server, host, port, false, callback);
}
public static Cancellable connectSocket(AsyncServer server, String host, int port, boolean trustAllCerts, ConnectCallback callback) {
SimpleCancellable cancellable = new SimpleCancellable();
Cancellable connect = server.connectSocket(host, port, (ex, netSocket) -> {
if (ex != null) {
if (cancellable.setComplete())
callback.onConnectCompleted(ex, null);
return;
}
handshake(netSocket, host, port,
(trustAllCerts ? trustAllSSLContext : defaultSSLContext).createSSLEngine(host, port),
trustAllCerts ? trustAllManagers : null,
trustAllCerts ? trustAllVerifier : null,
true, (e, socket) -> {
if (!cancellable.setComplete()) {
if (socket != null)
socket.close();
return;
}
if (e != null)
callback.onConnectCompleted(e, null);
else
callback.onConnectCompleted(null, socket);
});
});
cancellable.setParent(connect);
return cancellable;
}
boolean mEnded;
Exception mEndException;
final ByteBufferList pending = new ByteBufferList();
private AsyncSSLSocketWrapper(AsyncSocket socket,
String host, int port,
SSLEngine sslEngine,
TrustManager[] trustManagers, HostnameVerifier verifier, boolean clientMode) {
mSocket = socket;
hostnameVerifier = verifier;
this.clientMode = clientMode;
this.trustManagers = trustManagers;
this.engine = sslEngine;
mHost = host;
mPort = port;
engine.setUseClientMode(clientMode);
mSink = new BufferedDataSink(socket);
mSink.setWriteableCallback(new WritableCallback() {
@Override
public void onWriteable() {
if (mWriteableCallback != null)
mWriteableCallback.onWriteable();
}
});
// on pause, the emitter is paused to prevent the buffered
// socket and itself from firing.
// on resume, emitter is resumed, ssl buffer is flushed as well
mSocket.setEndCallback(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
if (mEnded)
return;
mEnded = true;
mEndException = ex;
if (!pending.hasRemaining() && mEndCallback != null)
mEndCallback.onCompleted(ex);
}
});
mSocket.setDataCallback(dataCallback);
}
final DataCallback dataCallback = new DataCallback() {
final Allocator allocator = new Allocator().setMinAlloc(8192);
final ByteBufferList buffered = new ByteBufferList();
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
if (mUnwrapping)
return;
try {
mUnwrapping = true;
bb.get(buffered);
if (buffered.hasRemaining()) {
ByteBuffer all = buffered.getAll();
buffered.add(all);
}
ByteBuffer b = ByteBufferList.EMPTY_BYTEBUFFER;
while (true) {
if (b.remaining() == 0 && buffered.size() > 0) {
b = buffered.remove();
}
int remaining = b.remaining();
int before = pending.remaining();
SSLEngineResult res;
{
// wrap to prevent access to the readBuf
ByteBuffer readBuf = allocator.allocate();
res = engine.unwrap(b, readBuf);
addToPending(pending, readBuf);
allocator.track(pending.remaining() - before);
}
if (res.getStatus() == Status.BUFFER_OVERFLOW) {
allocator.setMinAlloc(allocator.getMinAlloc() * 2);
remaining = -1;
}
else if (res.getStatus() == Status.BUFFER_UNDERFLOW) {
buffered.addFirst(b);
if (buffered.size() <= 1) {
break;
}
// pack it
remaining = -1;
b = buffered.getAll();
buffered.addFirst(b);
b = ByteBufferList.EMPTY_BYTEBUFFER;
}
handleHandshakeStatus(res.getHandshakeStatus());
if (b.remaining() == remaining && before == pending.remaining()) {
buffered.addFirst(b);
break;
}
}
AsyncSSLSocketWrapper.this.onDataAvailable();
}
catch (SSLException ex) {
// ex.printStackTrace();
report(ex);
}
finally {
mUnwrapping = false;
}
}
};
public void onDataAvailable() {
Util.emitAllData(this, pending);
if (mEnded && !pending.hasRemaining() && mEndCallback != null)
mEndCallback.onCompleted(mEndException);
}
@Override
public SSLEngine getSSLEngine() {
return engine;
}
void addToPending(ByteBufferList out, ByteBuffer mReadTmp) {
mReadTmp.flip();
if (mReadTmp.hasRemaining()) {
out.add(mReadTmp);
}
else {
ByteBufferList.reclaim(mReadTmp);
}
}
@Override
public void end() {
mSocket.end();
}
public String getHost() {
return mHost;
}
public int getPort() {
return mPort;
}
private void handleHandshakeStatus(HandshakeStatus status) {
if (status == HandshakeStatus.NEED_TASK) {
final Runnable task = engine.getDelegatedTask();
task.run();
}
if (status == HandshakeStatus.NEED_WRAP) {
write(writeList);
}
if (status == HandshakeStatus.NEED_UNWRAP) {
dataCallback.onDataAvailable(this, new ByteBufferList());
}
try {
if (!finishedHandshake && (engine.getHandshakeStatus() == HandshakeStatus.NOT_HANDSHAKING || engine.getHandshakeStatus() == HandshakeStatus.FINISHED)) {
if (clientMode) {
Exception peerUnverifiedCause = null;
boolean trusted = false;
try {
peerCertificates = (X509Certificate[]) engine.getSession().getPeerCertificates();
if (mHost != null) {
if (hostnameVerifier == null) {
StrictHostnameVerifier verifier = new StrictHostnameVerifier();
verifier.verify(mHost, StrictHostnameVerifier.getCNs(peerCertificates[0]), StrictHostnameVerifier.getDNSSubjectAlts(peerCertificates[0]));
}
else {
if (!hostnameVerifier.verify(mHost, engine.getSession())) {
throw new SSLException("hostname <" + mHost + "> has been denied");
}
}
}
trusted = true;
}
catch (SSLException ex) {
peerUnverifiedCause = ex;
}
finishedHandshake = true;
if (!trusted) {
AsyncSSLException e = new AsyncSSLException(peerUnverifiedCause);
report(e);
if (!e.getIgnore())
throw e;
}
}
else {
finishedHandshake = true;
}
handshakeCallback.onHandshakeCompleted(null, this);
handshakeCallback = null;
mSocket.setClosedCallback(null);
// handshake can complete during a wrap, so make sure that the call
// stack and wrap flag is cleared before invoking writable
getServer().post(new Runnable() {
@Override
public void run() {
if (mWriteableCallback != null)
mWriteableCallback.onWriteable();
}
});
onDataAvailable();
}
}
catch (Exception ex) {
report(ex);
}
}
int calculateAlloc(int remaining) {
// alloc 50% more than we need for writing
int alloc = remaining * 3 / 2;
if (alloc == 0)
alloc = 8192;
return alloc;
}
ByteBufferList writeList = new ByteBufferList();
@Override
public void write(ByteBufferList bb) {
if (mWrapping)
return;
if (mSink.remaining() > 0)
return;
mWrapping = true;
int remaining;
SSLEngineResult res = null;
ByteBuffer writeBuf = ByteBufferList.obtain(calculateAlloc(bb.remaining()));
do {
// if the handshake is finished, don't send
// 0 bytes of data, since that makes the ssl connection die.
// it wraps a 0 byte package, and craps out.
if (finishedHandshake && bb.remaining() == 0)
break;
remaining = bb.remaining();
try {
ByteBuffer[] arr = bb.getAllArray();
res = engine.wrap(arr, writeBuf);
bb.addAll(arr);
writeBuf.flip();
writeList.add(writeBuf);
if (writeList.remaining() > 0)
mSink.write(writeList);
int previousCapacity = writeBuf.capacity();
writeBuf = null;
if (res.getStatus() == Status.BUFFER_OVERFLOW) {
writeBuf = ByteBufferList.obtain(previousCapacity * 2);
remaining = -1;
}
else {
writeBuf = ByteBufferList.obtain(calculateAlloc(bb.remaining()));
handleHandshakeStatus(res.getHandshakeStatus());
}
}
catch (SSLException e) {
report(e);
}
}
while ((remaining != bb.remaining() || (res != null && res.getHandshakeStatus() == HandshakeStatus.NEED_WRAP)) && mSink.remaining() == 0);
mWrapping = false;
ByteBufferList.reclaim(writeBuf);
}
@Override
public void setWriteableCallback(WritableCallback handler) {
mWriteableCallback = handler;
}
@Override
public WritableCallback getWriteableCallback() {
return mWriteableCallback;
}
private void report(Exception e) {
final HandshakeCallback hs = handshakeCallback;
if (hs != null) {
handshakeCallback = null;
mSocket.setDataCallback(new DataCallback.NullDataCallback());
mSocket.end();
// handshake sets this callback. unset it.
mSocket.setClosedCallback(null);
mSocket.close();
hs.onHandshakeCompleted(e, null);
return;
}
CompletedCallback cb = getEndCallback();
if (cb != null)
cb.onCompleted(e);
}
@Override
public void setDataCallback(DataCallback callback) {
mDataCallback = callback;
}
@Override
public DataCallback getDataCallback() {
return mDataCallback;
}
@Override
public boolean isChunked() {
return mSocket.isChunked();
}
@Override
public boolean isOpen() {
return mSocket.isOpen();
}
@Override
public void close() {
mSocket.close();
}
@Override
public void setClosedCallback(CompletedCallback handler) {
mSocket.setClosedCallback(handler);
}
@Override
public CompletedCallback getClosedCallback() {
return mSocket.getClosedCallback();
}
CompletedCallback mEndCallback;
@Override
public void setEndCallback(CompletedCallback callback) {
mEndCallback = callback;
}
@Override
public CompletedCallback getEndCallback() {
return mEndCallback;
}
@Override
public void pause() {
mSocket.pause();
}
@Override
public void resume() {
mSocket.resume();
onDataAvailable();
}
@Override
public boolean isPaused() {
return mSocket.isPaused();
}
@Override
public AsyncServer getServer() {
return mSocket.getServer();
}
@Override
public AsyncSocket getSocket() {
return mSocket;
}
@Override
public DataEmitter getDataEmitter() {
return mSocket;
}
@Override
public X509Certificate[] getPeerCertificates() {
return peerCertificates;
}
@Override
public String charset() {
return null;
}
private static Certificate selfSign(KeyPair keyPair, String subjectDN) throws Exception
{
Provider bcProvider = new BouncyCastleProvider();
Security.addProvider(bcProvider);
long now = System.currentTimeMillis();
Date startDate = new Date(now);
X500Name dnName = new X500Name("CN=" + subjectDN);
BigInteger certSerialNumber = new BigInteger(Long.toString(now)); // <-- Using the current timestamp as the certificate serial number
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(Calendar.YEAR, 1); // <-- 1 Yr validity
Date endDate = calendar.getTime();
String signatureAlgorithm = "SHA256WithRSA"; // <-- Use appropriate signature algorithm based on your keyPair algorithm.
ContentSigner contentSigner = new JcaContentSignerBuilder(signatureAlgorithm).build(keyPair.getPrivate());
JcaX509v3CertificateBuilder certBuilder = new JcaX509v3CertificateBuilder(dnName, certSerialNumber, startDate, endDate, dnName, keyPair.getPublic());
// Extensions --------------------------
// Basic Constraints
BasicConstraints basicConstraints = new BasicConstraints(true); // <-- true for CA, false for EndEntity
certBuilder.addExtension(new ASN1ObjectIdentifier("2.5.29.19"), true, basicConstraints); // Basic Constraints is usually marked as critical.
// -------------------------------------
return new JcaX509CertificateConverter().setProvider(bcProvider).getCertificate(certBuilder.build(contentSigner));
}
public static Pair<KeyPair, Certificate> selfSignCertificate(final Context context, String subjectName) throws Exception {
File keyPath = context.getFileStreamPath(subjectName + "-key.txt");
KeyPair pair;
Certificate cert;
try {
String[] keyParts = StreamUtility.readFile(keyPath).split("\n");
X509EncodedKeySpec pub = new X509EncodedKeySpec(Base64.decode(keyParts[0], 0));
PKCS8EncodedKeySpec priv = new PKCS8EncodedKeySpec(Base64.decode(keyParts[1], 0));
cert = CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(Base64.decode(keyParts[2], 0)));
KeyFactory fact = KeyFactory.getInstance("RSA");
pair = new KeyPair(fact.generatePublic(pub), fact.generatePrivate(priv));
}
catch (Exception e) {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(2048);
pair = keyGen.generateKeyPair();
cert = selfSign(pair, subjectName);
StreamUtility.writeFile(keyPath,
Base64.encodeToString(pair.getPublic().getEncoded(), Base64.NO_WRAP)
+ "\n"
+ Base64.encodeToString(pair.getPrivate().getEncoded(), Base64.NO_WRAP)
+ "\n"
+ Base64.encodeToString(cert.getEncoded(), Base64.NO_WRAP));
}
return new Pair<>(pair, cert);
}
public static AsyncSSLServerSocket listenSecure(final Context context, final AsyncServer server, final String subjectName, final InetAddress host, final int port, final ListenCallback handler) {
final ObjectHolder<AsyncSSLServerSocket> holder = new ObjectHolder<>();
server.run(() -> {
try {
Pair<KeyPair, Certificate> keyCert = selfSignCertificate(context, subjectName);
KeyPair pair = keyCert.first;
Certificate cert = keyCert.second;
holder.held = listenSecure(server, pair.getPrivate(), cert, host, port, handler);
}
catch (Exception e) {
handler.onCompleted(e);
}
});
return holder.held;
}
public static AsyncSSLServerSocket listenSecure(AsyncServer server, String keyDer, String certDer, final InetAddress host, final int port, final ListenCallback handler) {
return listenSecure(server, Base64.decode(keyDer, Base64.DEFAULT), Base64.decode(certDer, Base64.DEFAULT), host, port, handler);
}
private static class ObjectHolder<T> {
T held;
}
public static AsyncSSLServerSocket listenSecure(final AsyncServer server, final byte[] keyDer, final byte[] certDer, final InetAddress host, final int port, final ListenCallback handler) {
final ObjectHolder<AsyncSSLServerSocket> holder = new ObjectHolder<>();
server.run(() -> {
try {
PKCS8EncodedKeySpec key = new PKCS8EncodedKeySpec(keyDer);
Certificate cert = CertificateFactory.getInstance("X.509").generateCertificate(new ByteArrayInputStream(certDer));
PrivateKey pk = KeyFactory.getInstance("RSA").generatePrivate(key);
holder.held = listenSecure(server, pk, cert, host, port, handler);
}
catch (Exception e) {
handler.onCompleted(e);
}
});
return holder.held;
}
public static AsyncSSLServerSocket listenSecure(final AsyncServer server, final PrivateKey pk, final Certificate cert, final InetAddress host, final int port, final ListenCallback handler) {
final ObjectHolder<AsyncSSLServerSocket> holder = new ObjectHolder<>();
server.run(() -> {
try {
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null);
ks.setKeyEntry("key", pk, null, new Certificate[] { cert });
KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
kmf.init(ks, "".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
final AsyncServerSocket socket = listenSecure(server, sslContext, host, port, handler);
holder.held = new AsyncSSLServerSocket() {
@Override
public PrivateKey getPrivateKey() {
return pk;
}
@Override
public Certificate getCertificate() {
return cert;
}
@Override
public void stop() {
socket.stop();
}
@Override
public int getLocalPort() {
return socket.getLocalPort();
}
};
}
catch (Exception e) {
handler.onCompleted(e);
}
});
return holder.held;
}
public static AsyncServerSocket listenSecure(AsyncServer server, final SSLContext sslContext, final InetAddress host, final int port, final ListenCallback handler) {
final SSLEngineSNIConfigurator conf = new SSLEngineSNIConfigurator() {
@Override
public SSLEngine createEngine(SSLContext sslContext, String peerHost, int peerPort) {
SSLEngine engine = super.createEngine(sslContext, peerHost, peerPort);
// String[] ciphers = engine.getEnabledCipherSuites();
// for (String cipher: ciphers) {
// Log.i(LOGTAG, cipher);
// }
// todo: what's this for? some vestigal vysor code i think. required by audio mirroring?
engine.setEnabledCipherSuites(new String[] { "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" });
return engine;
}
};
return server.listen(host, port, new ListenCallback() {
@Override
public void onAccepted(final AsyncSocket socket) {
AsyncSSLSocketWrapper.handshake(socket, null, port, conf.createEngine(sslContext, null, port), null, null, false,
(e, sslSocket) -> {
if (e != null) {
// chrome seems to do some sort of SSL probe and cancels handshakes. not sure why.
// i suspect it is to pick an optimal strong cipher.
// seeing a lot of the following in the log (but no actual connection errors)
// javax.net.ssl.SSLHandshakeException: error:10000416:SSL routines:OPENSSL_internal:SSLV3_ALERT_CERTIFICATE_UNKNOWN
// seen on Shield TV running API 26
// todo fix: conscrypt ssl context?
// Log.e(LOGTAG, "Error while handshaking", e);
socket.close();
return;
}
handler.onAccepted(sslSocket);
});
}
@Override
public void onListening(AsyncServerSocket socket) {
handler.onListening(socket);
}
@Override
public void onCompleted(Exception ex) {
handler.onCompleted(ex);
}
});
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSemaphore.java
================================================
package com.koushikdutta.async;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
public class AsyncSemaphore {
Semaphore semaphore = new Semaphore(0);
public void acquire() throws InterruptedException {
ThreadQueue threadQueue = ThreadQueue.getOrCreateThreadQueue(Thread.currentThread());
AsyncSemaphore last = threadQueue.waiter;
threadQueue.waiter = this;
Semaphore queueSemaphore = threadQueue.queueSemaphore;
try {
if (semaphore.tryAcquire())
return;
while (true) {
// run the queue
while (true) {
Runnable run = threadQueue.remove();
if (run == null)
break;
// Log.i(LOGTAG, "Pumping for AsyncSemaphore");
run.run();
}
int permits = Math.max(1, queueSemaphore.availablePermits());
queueSemaphore.acquire(permits);
if (semaphore.tryAcquire())
break;
}
}
finally {
threadQueue.waiter = last;
}
}
public boolean tryAcquire(long timeout, TimeUnit timeunit) throws InterruptedException {
long timeoutMs = TimeUnit.MILLISECONDS.convert(timeout, timeunit);
ThreadQueue threadQueue = ThreadQueue.getOrCreateThreadQueue(Thread.currentThread());
AsyncSemaphore last = threadQueue.waiter;
threadQueue.waiter = this;
Semaphore queueSemaphore = threadQueue.queueSemaphore;
try {
if (semaphore.tryAcquire())
return true;
long start = System.currentTimeMillis();
do {
// run the queue
while (true) {
Runnable run = threadQueue.remove();
if (run == null)
break;
// Log.i(LOGTAG, "Pumping for AsyncSemaphore");
run.run();
}
int permits = Math.max(1, queueSemaphore.availablePermits());
if (!queueSemaphore.tryAcquire(permits, timeoutMs, TimeUnit.MILLISECONDS))
return false;
if (semaphore.tryAcquire())
return true;
}
while (System.currentTimeMillis() - start < timeoutMs);
return false;
}
finally {
threadQueue.waiter = last;
}
}
public void release() {
semaphore.release();
ThreadQueue.release(this);
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncServer.java
================================================
package com.koushikdutta.async;
import android.os.Build;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Log;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.ConnectCallback;
import com.koushikdutta.async.callback.ListenCallback;
import com.koushikdutta.async.callback.SocketCreateCallback;
import com.koushikdutta.async.callback.ValueFunction;
import com.koushikdutta.async.future.Cancellable;
import com.koushikdutta.async.future.Future;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.async.future.SimpleCancellable;
import com.koushikdutta.async.future.SimpleFuture;
import com.koushikdutta.async.util.StreamUtility;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.spi.SelectorProvider;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class AsyncServer {
public static final String LOGTAG = "NIO";
private static class RunnableWrapper implements Runnable {
boolean hasRun;
Runnable runnable;
ThreadQueue threadQueue;
Handler handler;
@Override
public void run() {
synchronized (this) {
if (hasRun)
return;
hasRun = true;
}
try {
runnable.run();
}
finally {
threadQueue.remove(this);
handler.removeCallbacks(this);
threadQueue = null;
handler = null;
runnable = null;
}
}
}
public static void post(Handler handler, Runnable runnable) {
RunnableWrapper wrapper = new RunnableWrapper();
ThreadQueue threadQueue = ThreadQueue.getOrCreateThreadQueue(handler.getLooper().getThread());
wrapper.threadQueue = threadQueue;
wrapper.handler = handler;
wrapper.runnable = runnable;
// run it in a blocking AsyncSemaphore or a Handler, whichever gets to it first.
threadQueue.add(wrapper);
handler.post(wrapper);
// run the queue if the thread is blocking
threadQueue.queueSemaphore.release();
}
static {
try {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.FROYO) {
java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
}
}
catch (Throwable ex) {
}
}
static AsyncServer mInstance = new AsyncServer();
public static AsyncServer getDefault() {
return mInstance;
}
private SelectorWrapper mSelector;
public boolean isRunning() {
return mSelector != null;
}
String mName;
public AsyncServer() {
this(null);
}
public AsyncServer(String name) {
if (name == null)
name = "AsyncServer";
mName = name;
}
private static ExecutorService synchronousWorkers = newSynchronousWorkers("AsyncServer-worker-");
private static void wakeup(final SelectorWrapper selector) {
synchronousWorkers.execute(() -> {
try {
selector.wakeupOnce();
}
catch (Exception e) {
}
});
}
boolean killed;
public void kill() {
synchronized (this) {
killed = true;
}
stop(false);
}
int postCounter = 0;
public Cancellable postDelayed(Runnable runnable, long delay) {
Scheduled s;
synchronized (this) {
if (killed)
return SimpleCancellable.CANCELLED;
// Calculate when to run this queue item:
// If there is a delay (non-zero), add it to the current time
// When delay is zero, ensure that this follows all other
// zero-delay queue items. This is done by setting the
// "time" to the queue size. This will make sure it is before
// all time-delayed queue items (for all real world scenarios)
// as it will always be less than the current time and also remain
// behind all other immediately run queue items.
long time;
if (delay > 0)
time = SystemClock.elapsedRealtime() + delay;
else if (delay == 0)
time = postCounter++;
else if (mQueue.size() > 0)
time = Math.min(0, mQueue.peek().time - 1);
else
time = 0;
mQueue.add(s = new Scheduled(this, runnable, time));
// start the server up if necessary
if (mSelector == null)
run();
if (!isAffinityThread()) {
wakeup(mSelector);
}
}
return s;
}
public Cancellable postImmediate(Runnable runnable) {
if (Thread.currentThread() == getAffinity()) {
runnable.run();
return null;
}
return postDelayed(runnable, -1);
}
public Cancellable post(Runnable runnable) {
return postDelayed(runnable, 0);
}
public Cancellable post(final CompletedCallback callback, final Exception e) {
return post(() -> callback.onCompleted(e));
}
public void run(final Runnable runnable) {
if (Thread.currentThread() == mAffinity) {
post(runnable);
lockAndRunQueue(this, mQueue);
return;
}
final Semaphore semaphore;
synchronized (this) {
if (killed)
return;
semaphore = new Semaphore(0);
post(() -> {
runnable.run();
semaphore.release();
});
}
try {
semaphore.acquire();
}
catch (InterruptedException e) {
Log.e(LOGTAG, "run", e);
}
}
private static class Scheduled implements Cancellable, Runnable {
// this constructor is only called when the async execution should not be preserved
// ie... AsyncServer.stop.
public Scheduled(AsyncServer server, Runnable runnable, long time) {
this.server = server;
this.runnable = runnable;
this.time = time;
}
public AsyncServer server;
public Runnable runnable;
public long time;
@Override
public void run() {
this.runnable.run();
}
@Override
public boolean isDone() {
synchronized (server) {
return !cancelled && !server.mQueue.contains(this);
}
}
boolean cancelled;
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public boolean cancel() {
synchronized (server) {
return cancelled = server.mQueue.remove(this);
}
}
}
PriorityQueue<Scheduled> mQueue = new PriorityQueue<Scheduled>(1, Scheduler.INSTANCE);
static class Scheduler implements Comparator<Scheduled> {
public static Scheduler INSTANCE = new Scheduler();
private Scheduler() {
}
@Override
public int compare(Scheduled s1, Scheduled s2) {
// keep the smaller ones at the head, so they get tossed out quicker
if (s1.time == s2.time)
return 0;
if (s1.time > s2.time)
return 1;
return -1;
}
}
public void stop() {
stop(false);
}
public void stop(boolean wait) {
// Log.i(LOGTAG, "****AsyncServer is shutting down.****");
final SelectorWrapper currentSelector;
final Semaphore semaphore;
final boolean isAffinityThread;
synchronized (this) {
isAffinityThread = isAffinityThread();
currentSelector = mSelector;
if (currentSelector == null)
return;
semaphore = new Semaphore(0);
// post a shutdown and wait
mQueue.add(new Scheduled(this, new Runnable() {
@Override
public void run() {
shutdownEverything(currentSelector);
semaphore.release();
}
}, 0));
synchronousWorkers.execute(() -> {
try {
currentSelector.wakeupOnce();
}
catch (Exception e) {
}
});
// force any existing connections to die
shutdownKeys(currentSelector);
mQueue = new PriorityQueue<>(1, Scheduler.INSTANCE);
mSelector = null;
mAffinity = null;
}
try {
if (!isAffinityThread && wait)
semaphore.acquire();
}
catch (Exception e) {
}
}
protected void onDataReceived(int transmitted) {
}
protected void onDataSent(int transmitted) {
}
private static class ObjectHolder<T> {
T held;
}
public AsyncServerSocket listen(final InetAddress host, final int port, final ListenCallback handler) {
final ObjectHolder<AsyncServerSocket> holder = new ObjectHolder<>();
run(new Runnable() {
@Override
public void run() {
ServerSocketChannel closeableServer = null;
ServerSocketChannelWrapper closeableWrapper = null;
try {
closeableServer = ServerSocketChannel.open();
closeableWrapper = new ServerSocketChannelWrapper(
closeableServer);
final ServerSocketChannel server = closeableServer;
final ServerSocketChannelWrapper wrapper = closeableWrapper;
InetSocketAddress isa;
if (host == null)
isa = new InetSocketAddress(port);
else
isa = new InetSocketAddress(host, port);
server.socket().bind(isa);
final SelectionKey key = wrapper.register(mSelector.getSelector());
key.attach(handler);
handler.onListening(holder.held = new AsyncServerSocket() {
@Override
public int getLocalPort() {
return server.socket().getLocalPort();
}
@Override
public void stop() {
StreamUtility.closeQuietly(wrapper);
try {
key.cancel();
}
catch (Exception e) {
}
}
});
}
catch (IOException e) {
Log.e(LOGTAG, "wtf", e);
StreamUtility.closeQuietly(closeableWrapper, closeableServer);
handler.onCompleted(e);
}
}
});
return holder.held;
}
private class ConnectFuture extends SimpleFuture<AsyncNetworkSocket> {
@Override
protected void cancelCleanup() {
super.cancelCleanup();
try {
if (socket != null)
socket.close();
}
catch (IOException e) {
}
}
SocketChannel socket;
ConnectCallback callback;
}
public Cancellable connectResolvedInetSocketAddress(final InetSocketAddress address, final ConnectCallback callback) {
return connectResolvedInetSocketAddress(address, callback, null);
}
public ConnectFuture connectResolvedInetSocketAddress(final InetSocketAddress address, final ConnectCallback callback, final SocketCreateCallback createCallback) {
final ConnectFuture cancel = new ConnectFuture();
post(new Runnable() {
@Override
public void run() {
if (cancel.isCancelled())
return;
cancel.callback = callback;
SelectionKey ckey = null;
SocketChannel socket = null;
try {
socket = cancel.socket = SocketChannel.open();
socket.configureBlocking(false);
ckey = socket.register(mSelector.getSelector(), SelectionKey.OP_CONNECT);
ckey.attach(cancel);
if (createCallback != null)
createCallback.onSocketCreated(socket.socket().getLocalPort());
socket.connect(address);
}
catch (Throwable e) {
if (ckey != null)
ckey.cancel();
StreamUtility.closeQuietly(socket);
cancel.setComplete(new RuntimeException(e));
}
}
});
return cancel;
}
public Cancellable connectSocket(final InetSocketAddress remote, final ConnectCallback callback) {
if (!remote.isUnresolved())
return connectResolvedInetSocketAddress(remote, callback);
final SimpleFuture<AsyncNetworkSocket> ret = new SimpleFuture<AsyncNetworkSocket>();
Future<InetAddress> lookup = getByName(remote.getHostName());
ret.setParent(lookup);
lookup
.setCallback(new FutureCallback<InetAddress>() {
@Override
public void onCompleted(Exception e, InetAddress result) {
if (e != null) {
callback.onConnectCompleted(e, null);
ret.setComplete(e);
return;
}
ret.setComplete((ConnectFuture)connectResolvedInetSocketAddress(new InetSocketAddress(result, remote.getPort()), callback));
}
});
return ret;
}
public Cancellable connectSocket(final String host, final int port, final ConnectCallback callback) {
return connectSocket(InetSocketAddress.createUnresolved(host, port), callback);
}
private static ExecutorService newSynchronousWorkers(String prefix) {
ThreadFactory tf = new NamedThreadFactory(prefix);
ThreadPoolExecutor tpe = new ThreadPoolExecutor(0, 4, 10L,
TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), tf);
return tpe;
}
private static final Comparator<InetAddress> ipSorter = new Comparator<InetAddress>() {
@Override
public int compare(InetAddress lhs, InetAddress rhs) {
if (lhs instanceof Inet4Address && rhs instanceof Inet4Address)
return 0;
if (lhs instanceof Inet6Address && rhs instanceof Inet6Address)
return 0;
if (lhs instanceof Inet4Address && rhs instanceof Inet6Address)
return -1;
return 1;
}
};
private static ExecutorService synchronousResolverWorkers = newSynchronousWorkers("AsyncServer-resolver-");
public Future<InetAddress[]> getAllByName(final String host) {
final SimpleFuture<InetAddress[]> ret = new SimpleFuture<InetAddress[]>();
synchronousResolverWorkers.execute(new Runnable() {
@Override
public void run() {
try {
final InetAddress[] result = InetAddress.getAllByName(host);
Arrays.sort(result, ipSorter);
if (result == null || result.length == 0)
throw new HostnameResolutionException("no addresses for host");
post(new Runnable() {
@Override
public void run() {
ret.setComplete(null, result);
}
});
} catch (final Exception e) {
post(new Runnable() {
@Override
public void run() {
ret.setComplete(e, null);
}
});
}
}
});
return ret;
}
public Future<InetAddress> getByName(String host) {
return getAllByName(host).thenConvert(addresses -> addresses[0]);
}
private void handleSocket(final AsyncNetworkSocket handler) throws ClosedChannelException {
final ChannelWrapper sc = handler.getChannel();
SelectionKey ckey = sc.register(mSelector.getSelector());
ckey.attach(handler);
handler.setup(this, ckey);
}
public AsyncDatagramSocket connectDatagram(final String host, final int port) throws IOException {
final DatagramChannel socket = DatagramChannel.open();
final AsyncDatagramSocket handler = new AsyncDatagramSocket();
handler.attach(socket);
// ugh.. this should really be post to make it nonblocking...
// but i want datagrams to be immediately writable.
// they're not really used anyways.
run(new Runnable() {
@Override
public void run() {
try {
final SocketAddress remote = new InetSocketAddress(host, port);
handleSocket(handler);
socket.connect(remote);
}
catch (IOException e) {
Log.e(LOGTAG, "Datagram error", e);
StreamUtility.closeQuietly(socket);
}
}
});
return handler;
}
public AsyncDatagramSocket openDatagram() {
return openDatagram(null, 0, false);
}
public Cancellable createDatagram(String address, int port, boolean reuseAddress, FutureCallback<AsyncDatagramSocket> callback) {
return createDatagram(() -> InetAddress.getByName(address), port, reuseAddress, callback);
}
public Cancellable createDatagram(InetAddress address, int port, boolean reuseAddress, FutureCallback<AsyncDatagramSocket> callback) {
return createDatagram(() -> address, port, reuseAddress, callback);
}
private Cancellable createDatagram(ValueFunction<InetAddress> inetAddressValueFunction, final int port, final boolean reuseAddress, FutureCallback<AsyncDatagramSocket> callback) {
SimpleFuture<AsyncDatagramSocket> ret = new SimpleFuture<>();
ret.setCallback(callback);
post(() -> {
DatagramChannel socket = null;
try {
socket = DatagramChannel.open();
final AsyncDatagramSocket handler = new AsyncDatagramSocket();
handler.attach(socket);
InetSocketAddress address;
if (inetAddressValueFunction == null)
address = new InetSocketAddress(port);
else
address = new InetSocketAddress(inetAddressValueFunction.getValue(), port);
if (reuseAddress)
socket.socket().setReuseAddress(reuseAddress);
socket.socket().bind(address);
handleSocket(handler);
if (!ret.setComplete(handler))
socket.close();
}
catch (Exception e) {
StreamUtility.closeQuietly(socket);
ret.setComplete(e);
}
});
return ret;
}
public AsyncDatagramSocket openDatagram(final InetAddress host, final int port, final boolean reuseAddress) {
final AsyncDatagramSocket handler = new AsyncDatagramSocket();
// ugh.. this should really be post to make it nonblocking...
// but i want datagrams to be immediately writable.
// they're not really used anyways.
Runnable runnable = () -> {
final DatagramChannel socket;
try {
socket = DatagramChannel.open();
}
catch (Exception e) {
return;
}
try {
handler.attach(socket);
InetSocketAddress address;
if (host == null)
address = new InetSocketAddress(port);
else
address = new InetSocketAddress(host, port);
if (reuseAddress)
socket.socket().setReuseAddress(reuseAddress);
socket.socket().bind(address);
handleSocket(handler);
}
catch (IOException e) {
Log.e(LOGTAG, "Datagram error", e);
StreamUtility.closeQuietly(socket);
}
};
if (getAffinity() != Thread.currentThread()) {
run(runnable);
return handler;
}
runnable.run();
return handler;
}
public AsyncDatagramSocket connectDatagram(final SocketAddress remote) throws IOException {
final AsyncDatagramSocket handler = new AsyncDatagramSocket();
final DatagramChannel socket = DatagramChannel.open();
handler.attach(socket);
// ugh.. this should really be post to make it nonblocking...
// but i want datagrams to be immediately writable.
// they're not really used anyways.
Runnable runnable = () -> {
try {
handleSocket(handler);
socket.connect(remote);
}
catch (IOException e) {
StreamUtility.closeQuietly(socket);
}
};
if (getAffinity() != Thread.currentThread()) {
run(runnable);
return handler;
}
runnable.run();
return handler;
}
final private static ThreadLocal<AsyncServer> threadServer = new ThreadLocal<>();
public static AsyncServer getCurrentThreadServer() {
return threadServer.get();
}
Thread mAffinity;
private void run() {
final SelectorWrapper selector;
final PriorityQueue<Scheduled> queue;
synchronized (this) {
if (mSelector == null) {
try {
selector = mSelector = new SelectorWrapper(SelectorProvider.provider().openSelector());
queue = mQueue;
}
catch (IOException e) {
throw new RuntimeException("unable to create selector?", e);
}
mAffinity = new Thread(mName) {
public void run() {
try {
threadServer.set(AsyncServer.this);
AsyncServer.run(AsyncServer.this, selector, queue);
}
finally {
threadServer.remove();
}
}
};
mAffinity.start();
// kicked off the new thread, let's bail.
return;
}
// this is a reentrant call
selector = mSelector;
queue = mQueue;
// fall through to outside of the synchronization scope
// to allow the thread to run without locking.
}
try {
runLoop(this, selector, queue);
}
catch (AsyncSelectorException e) {
Log.i(LOGTAG, "Selector closed", e);
try {
// StreamUtility.closeQuiety is throwing ArrayStoreException?
selector.getSelector().close();
}
catch (Exception ex) {
}
}
}
private static void run(final AsyncServer server, final SelectorWrapper selector, final PriorityQueue<Scheduled> queue) {
// Log.i(LOGTAG, "****AsyncServer is starting.****");
// at this point, this local queue and selector are owned
// by this thread.
// if a stop is called, the instance queue and selector
// will be replaced and nulled respectively.
// this will allow the old queue and selector to shut down
// gracefully, while also allowing a new selector thread
// to start up while the old one is still shutting down.
while(true) {
try {
runLoop(server, selector, queue);
}
catch (AsyncSelectorException e) {
if (!(e.getCause() instanceof ClosedSelectorException))
Log.i(LOGTAG, "Selector exception, shutting down", e);
StreamUtility.closeQuietly(selector);
}
// see if we keep looping, this must be in a synchronized block since the queue is accessed.
synchronized (server) {
if (selector.isOpen() && (selector.keys().size() > 0 || queue.size() > 0))
continue;
shutdownEverything(selector);
if (server.mSelector == selector) {
server.mQueue = new PriorityQueue<Scheduled>(1, Scheduler.INSTANCE);
server.mSelector = null;
server.mAffinity = null;
}
break;
}
}
// Log.i(LOGTAG, "****AsyncServer has shut down.****");
}
private static void shutdownKeys(SelectorWrapper selector) {
try {
for (SelectionKey key: selector.keys()) {
StreamUtility.closeQuietly(key.channel());
try {
key.cancel();
}
catch (Exception e) {
}
}
}
catch (Exception ex) {
}
}
private static void shutdownEverything(SelectorWrapper selector) {
shutdownKeys(selector);
// SHUT. DOWN. EVERYTHING.
StreamUtility.closeQuietly(selector);
}
private static final long QUEUE_EMPTY = Long.MAX_VALUE;
private static long lockAndRunQueue(final AsyncServer server, final PriorityQueue<Scheduled> queue) {
long wait = QUEUE_EMPTY;
// find the first item we can actually run
while (true) {
Scheduled run = null;
synchronized (server) {
long now = SystemClock.elapsedRealtime();
if (queue.size() > 0) {
Scheduled s = queue.remove();
if (s.time <= now) {
run = s;
}
else {
wait = s.time - now;
queue.add(s);
}
}
}
if (run == null)
break;
run.run();
}
server.postCounter = 0;
return wait;
}
private static class AsyncSelectorException extends IOException {
public AsyncSelectorException(Exception e) {
super(e);
}
}
private static void runLoop(final AsyncServer server, final SelectorWrapper selector, final PriorityQueue<Scheduled> queue) throws AsyncSelectorException {
// Log.i(LOGTAG, "Keys: " + selector.keys().size());
boolean needsSelect = true;
// run the queue to populate the selector with keys
long wait = lockAndRunQueue(server, queue);
try {
synchronized (server) {
// select now to see if anything is ready immediately. this
// also clears the canceled key queue.
int readyNow = selector.selectNow();
if (readyNow == 0) {
// if there is nothing to select now, make sure we don't have an empty key set
// which means it would be time to turn this thread off.
if (selector.keys().size() == 0 && wait == QUEUE_EMPTY) {
// Log.i(LOGTAG, "Shutting down. keys: " + selector.keys().size() + " keepRunning: " + keepRunning);
return;
}
}
else {
needsSelect = false;
}
}
if (needsSelect) {
if (wait == QUEUE_EMPTY) {
// wait until woken up
selector.select();
}
else {
// nothing to select immediately but there's something pending so let's block that duration and wait.
selector.select(wait);
}
}
}
catch (Exception e) {
throw new AsyncSelectorException(e);
}
// process whatever keys are ready
Set<SelectionKey> readyKeys = selector.selectedKeys();
for (SelectionKey key: readyKeys) {
try {
if (key.isAcceptable()) {
ServerSocketChannel nextReady = (ServerSocketChannel) key.channel();
SocketChannel sc = null;
SelectionKey ckey = null;
try {
sc = nextReady.accept();
if (sc == null)
continue;
sc.configureBlocking(false);
ckey = sc.register(selector.getSelector(), SelectionKey.OP_READ);
ListenCallback serverHandler = (ListenCallback) key.attachment();
AsyncNetworkSocket handler = new AsyncNetworkSocket();
handler.attach(sc, (InetSocketAddress)sc.socket().getRemoteSocketAddress());
handler.setup(server, ckey);
ckey.attach(handler);
serverHandler.onAccepted(handler);
}
catch (IOException e) {
StreamUtility.closeQuietly(sc);
if (ckey != null)
ckey.cancel();
}
}
else if (key.isReadable()) {
AsyncNetworkSocket handler = (AsyncNetworkSocket) key.attachment();
int transmitted = handler.onReadable();
server.onDataReceived(transmitted);
}
else if (key.isWritable()) {
AsyncNetworkSocket handler = (AsyncNetworkSocket) key.attachment();
handler.onDataWritable();
}
else if (key.isConnectable()) {
ConnectFuture cancel = (ConnectFuture) key.attachment();
SocketChannel sc = (SocketChannel) key.channel();
key.interestOps(SelectionKey.OP_READ);
AsyncNetworkSocket newHandler;
try {
sc.finishConnect();
newHandler = new AsyncNetworkSocket();
newHandler.setup(server, key);
newHandler.attach(sc, (InetSocketAddress)sc.socket().getRemoteSocketAddress());
key.attach(newHandler);
}
catch (IOException ex) {
key.cancel();
StreamUtility.closeQuietly(sc);
if (cancel.setComplete(ex))
cancel.callback.onConnectCompleted(ex, null);
continue;
}
if (cancel.setComplete(newHandler))
cancel.callback.onConnectCompleted(null, newHandler);
}
else {
Log.i(LOGTAG, "wtf");
throw new RuntimeException("Unknown key state.");
}
}
catch (CancelledKeyException ex) {
}
}
readyKeys.clear();
}
public void dump() {
post(new Runnable() {
@Override
public void run() {
if (mSelector == null) {
Log.i(LOGTAG, "Server dump not possible. No selector?");
return;
}
Log.i(LOGTAG, "Key Count: " + mSelector.keys().size());
for (SelectionKey key: mSelector.keys()) {
Log.i(LOGTAG, "Key: " + key);
}
}
});
}
public Thread getAffinity() {
return mAffinity;
}
public boolean isAffinityThread() {
return mAffinity == Thread.currentThread();
}
public boolean isAffinityThreadOrStopped() {
Thread affinity = mAffinity;
return affinity == null || affinity == Thread.currentThread();
}
private static class NamedThreadFactory implements ThreadFactory {
private final ThreadGroup group;
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix;
NamedThreadFactory(String namePrefix) {
SecurityManager s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() :
Thread.currentThread().getThreadGroup();
this.namePrefix = namePrefix;
}
public Thread newThread(Runnable r) {
Thread t = new Thread(group, r,
namePrefix + threadNumber.getAndIncrement(), 0);
if (t.isDaemon()) t.setDaemon(false);
if (t.getPriority() != Thread.NORM_PRIORITY) {
t.setPriority(Thread.NORM_PRIORITY);
}
return t;
}
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncServerSocket.java
================================================
package com.koushikdutta.async;
public interface AsyncServerSocket {
public void stop();
public int getLocalPort();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSocket.java
================================================
package com.koushikdutta.async;
public interface AsyncSocket extends DataEmitter, DataSink {
public AsyncServer getServer();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/BufferedDataSink.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.WritableCallback;
public class BufferedDataSink implements DataSink {
DataSink mDataSink;
public BufferedDataSink(DataSink datasink) {
setDataSink(datasink);
}
public boolean isBuffering() {
return mPendingWrites.hasRemaining() || forceBuffering;
}
public boolean isWritable() {
synchronized (mPendingWrites) {
return mPendingWrites.remaining() < mMaxBuffer;
}
}
public DataSink getDataSink() {
return mDataSink;
}
boolean forceBuffering;
public void forceBuffering(boolean forceBuffering) {
this.forceBuffering = forceBuffering;
if (!forceBuffering)
writePending();
}
public void setDataSink(DataSink datasink) {
mDataSink = datasink;
mDataSink.setWriteableCallback(this::writePending);
}
private void writePending() {
if (forceBuffering)
return;
// Log.i("NIO", "Writing to buffer...");
boolean empty;
synchronized (mPendingWrites) {
mDataSink.write(mPendingWrites);
empty = mPendingWrites.isEmpty();
}
if (empty) {
if (endPending)
mDataSink.end();
}
if (empty && mWritable != null)
mWritable.onWriteable();
}
final ByteBufferList mPendingWrites = new ByteBufferList();
// before the data is queued, let inheritors know. allows for filters, without
// issues with having to filter before writing which may fail in the buffer.
protected void onDataAccepted(ByteBufferList bb) {
}
@Override
public void write(final ByteBufferList bb) {
if (getServer().getAffinity() != Thread.currentThread()) {
synchronized (mPendingWrites) {
if (mPendingWrites.remaining() >= mMaxBuffer)
return;
onDataAccepted(bb);
bb.get(mPendingWrites);
}
getServer().post(this::writePending);
return;
}
onDataAccepted(bb);
if (!isBuffering())
mDataSink.write(bb);
synchronized (mPendingWrites) {
bb.get(mPendingWrites);
}
}
WritableCallback mWritable;
@Override
public void setWriteableCallback(WritableCallback handler) {
mWritable = handler;
}
@Override
public WritableCallback getWriteableCallback() {
return mWritable;
}
public int remaining() {
return mPendingWrites.remaining();
}
int mMaxBuffer = Integer.MAX_VALUE;
public int getMaxBuffer() {
return mMaxBuffer;
}
public void setMaxBuffer(int maxBuffer) {
mMaxBuffer = maxBuffer;
}
@Override
public boolean isOpen() {
return mDataSink.isOpen();
}
boolean endPending;
@Override
public void end() {
if (getServer().getAffinity() != Thread.currentThread()) {
getServer().post(this::end);
return;
}
synchronized (mPendingWrites) {
if (mPendingWrites.hasRemaining()) {
endPending = true;
return;
}
}
mDataSink.end();
}
@Override
public void setClosedCallback(CompletedCallback handler) {
mDataSink.setClosedCallback(handler);
}
@Override
public CompletedCallback getClosedCallback() {
return mDataSink.getClosedCallback();
}
@Override
public AsyncServer getServer() {
return mDataSink.getServer();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java
================================================
package com.koushikdutta.async;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Looper;
import com.koushikdutta.async.util.ArrayDeque;
import com.koushikdutta.async.util.Charsets;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
import java.util.Comparator;
import java.util.PriorityQueue;
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public class ByteBufferList {
ArrayDeque<ByteBuffer> mBuffers = new ArrayDeque<ByteBuffer>();
ByteOrder order = ByteOrder.BIG_ENDIAN;
public ByteOrder order() {
return order;
}
public ByteBufferList order(ByteOrder order) {
this.order = order;
return this;
}
public ByteBufferList() {
}
public ByteBufferList(ByteBuffer... b) {
addAll(b);
}
public ByteBufferList(byte[] buf) {
super();
ByteBuffer b = ByteBuffer.wrap(buf);
add(b);
}
public ByteBufferList addAll(ByteBuffer... bb) {
for (ByteBuffer b: bb)
add(b);
return this;
}
public ByteBufferList addAll(ByteBufferList... bb) {
for (ByteBufferList b: bb)
b.get(this);
return this;
}
public byte[] getBytes(int length) {
byte[] ret = new byte[length];
get(ret);
return ret;
}
public byte[] getAllByteArray() {
byte[] ret = new byte[remaining()];
get(ret);
return ret;
}
public ByteBuffer[] getAllArray() {
ByteBuffer[] ret = new ByteBuffer[mBuffers.size()];
ret = mBuffers.toArray(ret);
mBuffers.clear();
remaining = 0;
return ret;
}
public boolean isEmpty() {
return remaining == 0;
}
private int remaining = 0;
public int remaining() {
return remaining;
}
public boolean hasRemaining() {
return remaining() > 0;
}
public short peekShort() {
return read(2).getShort(mBuffers.peekFirst().position());
}
public byte peek() {
return read(1).get(mBuffers.peekFirst().position());
}
public int peekInt() {
return read(4).getInt(mBuffers.peekFirst().position());
}
public long peekLong() {
return read(8).getLong(mBuffers.peekFirst().position());
}
public byte[] peekBytes(int size) {
byte[] ret = new byte[size];
read(size).get(ret, mBuffers.peekFirst().position(), ret.length);
return ret;
}
public ByteBufferList skip(int length) {
get(null, 0, length);
return this;
}
public int getInt() {
int ret = read(4).getInt();
remaining -= 4;
return ret;
}
public char getByteChar() {
char ret = (char)read(1).get();
remaining--;
return ret;
}
public short getShort() {
short ret = read(2).getShort();
remaining -= 2;
return ret;
}
public byte get() {
byte ret = read(1).get();
remaining--;
return ret;
}
public long getLong() {
long ret = read(8).getLong();
remaining -= 8;
return ret;
}
public void get(byte[] bytes) {
get(bytes, 0, bytes.length);
}
public void get(byte[] bytes, int offset, int length) {
if (remaining() < length)
throw new IllegalArgumentException("length");
int need = length;
while (need > 0) {
ByteBuffer b = mBuffers.peek();
int read = Math.min(b.remaining(), need);
if (bytes != null){
b.get(bytes, offset, read);
} else {
//when bytes is null, just skip data.
b.position(b.position() + read);
}
need -= read;
offset += read;
if (b.remaining() == 0) {
ByteBuffer removed = mBuffers.remove();
reclaim(b);
}
}
remaining -= length;
}
public void get(ByteBufferList into, int length) {
if (remaining() < length)
throw new IllegalArgumentException("length");
int offset = 0;
while (offset < length) {
ByteBuffer b = mBuffers.remove();
int remaining = b.remaining();
if (remaining == 0) {
reclaim(b);
continue;
}
if (offset + remaining > length) {
int need = length - offset;
// this is shared between both
ByteBuffer subset = obtain(need);
subset.limit(need);
b.get(subset.array(), 0, need);
into.add(subset);
mBuffers.addFirst(b);
break;
}
else {
// this belongs to the new list
into.add(b);
}
offset += remaining;
}
remaining -= length;
}
public void get(ByteBufferList into) {
get(into, remaining());
}
public ByteBufferList get(int length) {
ByteBufferList ret = new ByteBufferList();
get(ret, length);
return ret.order(order);
}
public ByteBuffer getAll() {
if (remaining() == 0)
return EMPTY_BYTEBUFFER;
read(remaining());
return remove();
}
private ByteBuffer read(int count) {
if (remaining() < count)
throw new IllegalArgumentException("count : " + remaining() + "/" + count);
ByteBuffer first = mBuffers.peek();
while (first != null && !first.hasRemaining()) {
reclaim(mBuffers.remove());
first = mBuffers.peek();
}
if (first == null) {
return EMPTY_BYTEBUFFER;
}
if (first.remaining() >= count) {
return first.order(order);
}
ByteBuffer ret = obtain(count);
ret.limit(count);
byte[] bytes = ret.array();
int offset = 0;
ByteBuffer bb = null;
while (offset < count) {
bb = mBuffers.remove();
int toRead = Math.min(count - offset, bb.remaining());
bb.get(bytes, offset, toRead);
offset += toRead;
if (bb.remaining() == 0) {
reclaim(bb);
bb = null;
}
}
// if there was still data left in the last buffer we popped
// toss it back into the head
if (bb != null && bb.remaining() > 0)
mBuffers.addFirst(bb);
mBuffers.addFirst(ret);
return ret.order(order);
}
public void trim() {
// this clears out buffers that are empty in the beginning of the list
read(0);
}
public ByteBufferList add(ByteBufferList b) {
b.get(this);
return this;
}
public ByteBufferList add(ByteBuffer b) {
if (b.remaining() <= 0) {
// System.out.println("reclaiming remaining: " + b.remaining());
reclaim(b);
return this;
}
addRemaining(b.remaining());
// see if we can fit the entirety of the buffer into the end
// of the current last buffer
if (mBuffers.size() > 0) {
ByteBuffer last = mBuffers.getLast();
if (last.capacity() - last.limit() >= b.remaining()) {
last.mark();
last.position(last.limit());
last.limit(last.capacity());
last.put(b);
last.limit(last.position());
last.reset();
reclaim(b);
trim();
return this;
}
}
mBuffers.add(b);
trim();
return this;
}
public void addFirst(ByteBuffer b) {
if (b.remaining() <= 0) {
reclaim(b);
return;
}
addRemaining(b.remaining());
// see if we can fit the entirety of the buffer into the beginning
// of the current first buffer
if (mBuffers.size() > 0) {
ByteBuffer first = mBuffers.getFirst();
if (first.position() >= b.remaining()) {
first.position(first.position() - b.remaining());
first.mark();
first.put(b);
first.reset();
reclaim(b);
return;
}
}
mBuffers.addFirst(b);
}
private void addRemaining(int remaining) {
if (this.remaining() >= 0)
this.remaining += remaining;
}
public void recycle() {
while (mBuffers.size() > 0) {
reclaim(mBuffers.remove());
}
remaining = 0;
}
public ByteBuffer remove() {
ByteBuffer ret = mBuffers.remove();
remaining -= ret.remaining();
return ret;
}
public int size() {
return mBuffers.size();
}
public void spewString() {
System.out.println(peekString());
}
public String peekString() {
return peekString(null);
}
// not doing toString as this is really nasty in the debugger...
public String peekString(Charset charset) {
if (charset == null)
charset = Charsets.UTF_8;
StringBuilder builder = new StringBuilder();
for (ByteBuffer bb: mBuffers) {
byte[] bytes;
int offset;
int length;
if (bb.isDirect()) {
bytes = new byte[bb.remaining()];
offset = 0;
length = bb.remaining();
bb.get(bytes);
}
else {
bytes = bb.array();
offset = bb.arrayOffset() + bb.position();
length = bb.remaining();
}
builder.append(new String(bytes, offset, length, charset));
}
return builder.toString();
}
public String readString() {
return readString(null);
}
public String readString(Charset charset) {
String ret = peekString(charset);
recycle();
return ret;
}
static class Reclaimer implements Comparator<ByteBuffer> {
@Override
public int compare(ByteBuffer byteBuffer, ByteBuffer byteBuffer2) {
// keep the smaller ones at the head, so they get tossed out quicker
if (byteBuffer.capacity() == byteBuffer2.capacity())
return 0;
if (byteBuffer.capacity() > byteBuffer2.capacity())
return 1;
return -1;
}
}
static PriorityQueue<ByteBuffer> reclaimed = new PriorityQueue<ByteBuffer>(8, new Reclaimer());
private static PriorityQueue<ByteBuffer> getReclaimed() {
Looper mainLooper = Looper.getMainLooper();
if (mainLooper != null) {
if (Thread.currentThread() == mainLooper.getThread())
return null;
}
return reclaimed;
}
private static int MAX_SIZE = 1024 * 1024;
public static int MAX_ITEM_SIZE = 1024 * 256;
static int currentSize = 0;
static int maxItem = 0;
public static void setMaxPoolSize(int size) {
MAX_SIZE = size;
}
public static void setMaxItemSize(int size) {
MAX_ITEM_SIZE = size;
}
private static boolean reclaimedContains(ByteBuffer b) {
for (ByteBuffer other: reclaimed) {
if (other == b)
return true;
}
return false;
}
public static void reclaim(ByteBuffer b) {
if (b == null || b.isDirect())
return;
if (b.arrayOffset() != 0 || b.array().length != b.capacity())
return;
if (b.capacity() < 8192)
return;
if (b.capacity() > MAX_ITEM_SIZE)
return;
PriorityQueue<ByteBuffer> r = getReclaimed();
if (r == null)
return;
synchronized (LOCK) {
while (currentSize > MAX_SIZE && r.size() > 0 && r.peek().capacity() < b.capacity()) {
// System.out.println("removing for better: " + b.capacity());
ByteBuffer head = r.remove();
currentSize -= head.capacity();
}
if (currentSize > MAX_SIZE) {
// System.out.println("too full: " + b.capacity());
return;
}
b.position(0);
b.limit(b.capacity());
currentSize += b.capacity();
r.add(b);
maxItem = Math.max(maxItem, b.capacity());
}
}
private static final Object LOCK = new Object();
public static ByteBuffer obtain(int size) {
if (size <= maxItem) {
PriorityQueue<ByteBuffer> r = getReclaimed();
if (r != null) {
synchronized (LOCK) {
while (r.size() > 0) {
ByteBuffer ret = r.remove();
if (r.size() == 0)
maxItem = 0;
currentSize -= ret.capacity();
if (ret.capacity() >= size) {
// System.out.println("using " + ret.capacity());
return ret;
}
// System.out.println("dumping " + ret.capacity());
}
}
}
}
// System.out.println("alloc for " + size);
ByteBuffer ret = ByteBuffer.allocate(Math.max(8192, size));
return ret;
}
public static void obtainArray(ByteBuffer[] arr, int size) {
PriorityQueue<ByteBuffer> r = getReclaimed();
int index = 0;
int total = 0;
if (r != null) {
synchronized (LOCK) {
while (r.size() > 0 && total < size && index < arr.length - 1) {
ByteBuffer b = r.remove();
currentSize -= b.capacity();
int needed = Math.min(size - total, b.capacity());
total += needed;
arr[index++] = b;
}
}
}
if (total < size) {
ByteBuffer b = ByteBuffer.allocate(Math.max(8192, size - total));
arr[index++] = b;
}
for (int i = index; i < arr.length; i++) {
arr[i] = EMPTY_BYTEBUFFER;
}
}
public static ByteBuffer deepCopy(ByteBuffer copyOf) {
if (copyOf == null)
return null;
return (ByteBuffer)obtain(copyOf.remaining()).put(copyOf.duplicate()).flip();
}
public static final ByteBuffer EMPTY_BYTEBUFFER = ByteBuffer.allocate(0);
public static void writeOutputStream(OutputStream out, ByteBuffer b) throws IOException {
byte[] bytes;
int offset;
int length;
if (b.isDirect()) {
bytes = new byte[b.remaining()];
offset = 0;
length = b.remaining();
b.get(bytes);
}
else {
bytes = b.array();
offset = b.arrayOffset() + b.position();
length = b.remaining();
}
out.write(bytes, offset, length);
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java
================================================
package com.koushikdutta.async;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.ScatteringByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.spi.AbstractSelectableChannel;
abstract class ChannelWrapper implements ReadableByteChannel, ScatteringByteChannel {
private AbstractSelectableChannel mChannel;
ChannelWrapper(AbstractSelectableChannel channel) throws IOException {
channel.configureBlocking(false);
mChannel = channel;
}
public abstract void shutdownInput();
public abstract void shutdownOutput();
public abstract boolean isConnected();
public abstract int write(ByteBuffer src) throws IOException;
public abstract int write(ByteBuffer[] src) throws IOException;
// register for default events appropriate for this channel
public abstract SelectionKey register(Selector sel) throws ClosedChannelException;
public SelectionKey register(Selector sel, int ops) throws ClosedChannelException {
return mChannel.register(sel, ops);
}
public boolean isChunked() {
return false;
}
@Override
public boolean isOpen() {
return mChannel.isOpen();
}
@Override
public void close() throws IOException {
mChannel.close();
}
public abstract int getLocalPort();
public abstract InetAddress getLocalAddress();
public abstract Object getSocket();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/DataEmitter.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.DataCallback;
public interface DataEmitter {
void setDataCallback(DataCallback callback);
DataCallback getDataCallback();
boolean isChunked();
void pause();
void resume();
void close();
boolean isPaused();
void setEndCallback(CompletedCallback callback);
CompletedCallback getEndCallback();
AsyncServer getServer();
String charset();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/DataEmitterBase.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.DataCallback;
/**
* Created by koush on 5/27/13.
*/
public abstract class DataEmitterBase implements DataEmitter {
private boolean ended;
protected void report(Exception e) {
if (ended)
return;
ended = true;
if (getEndCallback() != null)
getEndCallback().onCompleted(e);
}
@Override
public final void setEndCallback(CompletedCallback callback) {
endCallback = callback;
}
CompletedCallback endCallback;
@Override
public final CompletedCallback getEndCallback() {
return endCallback;
}
DataCallback mDataCallback;
@Override
public void setDataCallback(DataCallback callback) {
mDataCallback = callback;
}
@Override
public DataCallback getDataCallback() {
return mDataCallback;
}
@Override
public String charset() {
return null;
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.DataCallback;
public class DataEmitterReader implements com.koushikdutta.async.callback.DataCallback {
DataCallback mPendingRead;
int mPendingReadLength;
ByteBufferList mPendingData = new ByteBufferList();
public void read(int count, DataCallback callback) {
mPendingReadLength = count;
mPendingRead = callback;
mPendingData.recycle();
}
private boolean handlePendingData(DataEmitter emitter) {
if (mPendingReadLength > mPendingData.remaining())
return false;
DataCallback pendingRead = mPendingRead;
mPendingRead = null;
pendingRead.onDataAvailable(emitter, mPendingData);
return true;
}
public DataEmitterReader() {
}
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
// if we're registered for data, we must be waiting for a read
do {
int need = Math.min(bb.remaining(), mPendingReadLength - mPendingData.remaining());
bb.get(mPendingData, need);
bb.remaining();
}
while (handlePendingData(emitter) && mPendingRead != null);
bb.remaining();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/DataSink.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.WritableCallback;
public interface DataSink {
public void write(ByteBufferList bb);
public void setWriteableCallback(WritableCallback handler);
public WritableCallback getWriteableCallback();
public boolean isOpen();
public void end();
public void setClosedCallback(CompletedCallback handler);
public CompletedCallback getClosedCallback();
public AsyncServer getServer();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/DataTrackingEmitter.java
================================================
package com.koushikdutta.async;
/**
* Created by koush on 5/28/13.
*/
public interface DataTrackingEmitter extends DataEmitter {
interface DataTracker {
void onData(int totalBytesRead);
}
void setDataTracker(DataTracker tracker);
DataTracker getDataTracker();
int getBytesRead();
void setDataEmitter(DataEmitter emitter);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java
================================================
package com.koushikdutta.async;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
class DatagramChannelWrapper extends ChannelWrapper {
DatagramChannel mChannel;
@Override
public InetAddress getLocalAddress() {
return mChannel.socket().getLocalAddress();
}
@Override
public int getLocalPort() {
return mChannel.socket().getLocalPort();
}
InetSocketAddress address;
public InetSocketAddress getRemoteAddress() {
return address;
}
public void disconnect() throws IOException {
mChannel.disconnect();
}
DatagramChannelWrapper(DatagramChannel channel) throws IOException {
super(channel);
mChannel = channel;
}
@Override
public int read(ByteBuffer buffer) throws IOException {
if (!isConnected()) {
int position = buffer.position();
address = (InetSocketAddress)mChannel.receive(buffer);
if (address == null)
return -1;
return buffer.position() - position;
}
address = null;
return mChannel.read(buffer);
}
@Override
public boolean isConnected() {
return mChannel.isConnected();
}
@Override
public int write(ByteBuffer src) throws IOException {
return mChannel.write(src);
}
@Override
public int write(ByteBuffer[] src) throws IOException {
return (int)mChannel.write(src);
}
@Override
public SelectionKey register(Selector sel, int ops) throws ClosedChannelException {
return mChannel.register(sel, ops);
}
@Override
public boolean isChunked() {
return true;
}
@Override
public SelectionKey register(Selector sel) throws ClosedChannelException {
return register(sel, SelectionKey.OP_READ);
}
@Override
public void shutdownOutput() {
}
@Override
public void shutdownInput() {
}
@Override
public long read(ByteBuffer[] byteBuffers) throws IOException {
return mChannel.read(byteBuffers);
}
@Override
public long read(ByteBuffer[] byteBuffers, int i, int i2) throws IOException {
return mChannel.read(byteBuffers, i, i2);
}
@Override
public Object getSocket() {
return mChannel.socket();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/FileDataEmitter.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.DataCallback;
import com.koushikdutta.async.util.StreamUtility;
import java.io.File;
import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
/**
* Created by koush on 5/22/13.
*/
public class FileDataEmitter extends DataEmitterBase {
AsyncServer server;
File file;
public FileDataEmitter(AsyncServer server, File file) {
this.server = server;
this.file = file;
paused = !server.isAffinityThread();
if (!paused)
doResume();
}
DataCallback callback;
@Override
public void setDataCallback(DataCallback callback) {
this.callback = callback;
}
@Override
public DataCallback getDataCallback() {
return callback;
}
@Override
public boolean isChunked() {
return false;
}
boolean paused;
@Override
public void pause() {
paused = true;
}
@Override
public void resume() {
paused = false;
doResume();
}
@Override
protected void report(Exception e) {
StreamUtility.closeQuietly(channel);
super.report(e);
}
ByteBufferList pending = new ByteBufferList();
FileChannel channel;
Runnable pumper = new Runnable() {
@Override
public void run() {
try {
if (channel == null)
channel = new FileInputStream(file).getChannel();
if (!pending.isEmpty()) {
Util.emitAllData(FileDataEmitter.this, pending);
if (!pending.isEmpty())
return;
}
ByteBuffer b;
do {
b = ByteBufferList.obtain(8192);
if (-1 == channel.read(b)) {
report(null);
return;
}
b.flip();
pending.add(b);
Util.emitAllData(FileDataEmitter.this, pending);
}
while (pending.remaining() == 0 && !isPaused());
}
catch (Exception e) {
report(e);
}
}
};
private void doResume() {
server.post(pumper);
}
@Override
public boolean isPaused() {
return paused;
}
@Override
public AsyncServer getServer() {
return server;
}
@Override
public void close() {
try {
channel.close();
}
catch (Exception e) {
}
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/FilteredDataEmitter.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.DataCallback;
import com.koushikdutta.async.wrapper.DataEmitterWrapper;
public class FilteredDataEmitter extends DataEmitterBase implements DataEmitter, DataCallback, DataEmitterWrapper, DataTrackingEmitter {
private DataEmitter mEmitter;
@Override
public DataEmitter getDataEmitter() {
return mEmitter;
}
@Override
public void setDataEmitter(DataEmitter emitter) {
if (mEmitter != null) {
mEmitter.setDataCallback(null);
}
mEmitter = emitter;
mEmitter.setDataCallback(this);
mEmitter.setEndCallback(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
report(ex);
}
});
}
@Override
public int getBytesRead() {
return totalRead;
}
@Override
public DataTracker getDataTracker() {
return tracker;
}
@Override
public void setDataTracker(DataTracker tracker) {
this.tracker = tracker;
}
private DataTracker tracker;
private int totalRead;
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
if (closed) {
// this emitter was closed but for some reason data is still being spewed...
// eat it, nom nom.
bb.recycle();
return;
}
if (bb != null)
totalRead += bb.remaining();
Util.emitAllData(this, bb);
if (bb != null)
totalRead -= bb.remaining();
if (tracker != null && bb != null)
tracker.onData(totalRead);
// if there's data after the emitting, and it is paused... the underlying implementation
// is obligated to cache the byte buffer list.
}
@Override
public boolean isChunked() {
return mEmitter.isChunked();
}
@Override
public void pause() {
mEmitter.pause();
}
@Override
public void resume() {
mEmitter.resume();
}
@Override
public boolean isPaused() {
return mEmitter.isPaused();
}
@Override
public AsyncServer getServer() {
return mEmitter.getServer();
}
boolean closed;
@Override
public void close() {
closed = true;
if (mEmitter != null)
mEmitter.close();
}
@Override
public String charset() {
if (mEmitter == null)
return null;
return mEmitter.charset();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/FilteredDataSink.java
================================================
package com.koushikdutta.async;
public class FilteredDataSink extends BufferedDataSink {
public FilteredDataSink(DataSink sink) {
super(sink);
setMaxBuffer(0);
}
public ByteBufferList filter(ByteBufferList bb) {
return bb;
}
@Override
protected void onDataAccepted(ByteBufferList bb) {
ByteBufferList filtered = filter(bb);
// filtering may return the same byte buffer, so watch for that.
if (filtered != bb) {
bb.recycle();
filtered.get(bb);
}
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/HostnameResolutionException.java
================================================
package com.koushikdutta.async;
public class HostnameResolutionException extends Exception {
public HostnameResolutionException(String message) {
super(message);
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/LineEmitter.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.DataCallback;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
public class LineEmitter implements DataCallback {
public interface StringCallback {
void onStringAvailable(String s);
}
public LineEmitter() {
this(null);
}
public LineEmitter(Charset charset) {
this.charset = charset;
}
Charset charset;
ByteBufferList data = new ByteBufferList();
StringCallback mLineCallback;
public void setLineCallback(StringCallback callback) {
mLineCallback = callback;
}
public StringCallback getLineCallback() {
return mLineCallback;
}
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
ByteBuffer buffer = ByteBuffer.allocate(bb.remaining());
while (bb.remaining() > 0) {
byte b = bb.get();
if (b == '\n') {
buffer.flip();
data.add(buffer);
mLineCallback.onStringAvailable(data.readString(charset));
data = new ByteBufferList();
return;
}
else {
buffer.put(b);
}
}
buffer.flip();
data.add(buffer);
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/PushParser.java
================================================
package com.koushikdutta.async;
import android.util.Log;
import com.koushikdutta.async.callback.DataCallback;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.LinkedList;
public class PushParser implements DataCallback {
public interface ParseCallback<T> {
public void parsed(T data);
}
static abstract class Waiter {
int length;
public Waiter(int length) {
this.length = length;
}
/**
* Consumes received data, and/or returns next waiter to continue reading instead of this waiter.
* @param bb received data, bb.remaining >= length
* @return - a waiter that should continue reading right away, or null if this waiter is finished
*/
public abstract Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb);
}
static class IntWaiter extends Waiter {
ParseCallback<Integer> callback;
public IntWaiter(ParseCallback<Integer> callback) {
super(4);
this.callback = callback;
}
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
callback.parsed(bb.getInt());
return null;
}
}
static class ByteArrayWaiter extends Waiter {
ParseCallback<byte[]> callback;
public ByteArrayWaiter(int length, ParseCallback<byte[]> callback) {
super(length);
if (length <= 0)
throw new IllegalArgumentException("length should be > 0");
this.callback = callback;
}
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
byte[] bytes = new byte[length];
bb.get(bytes);
callback.parsed(bytes);
return null;
}
}
static class LenByteArrayWaiter extends Waiter {
private final ParseCallback<byte[]> callback;
public LenByteArrayWaiter(ParseCallback<byte[]> callback) {
super(4);
this.callback = callback;
}
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
int length = bb.getInt();
if (length == 0) {
callback.parsed(new byte[0]);
return null;
}
return new ByteArrayWaiter(length, callback);
}
}
static class ByteBufferListWaiter extends Waiter {
ParseCallback<ByteBufferList> callback;
public ByteBufferListWaiter(int length, ParseCallback<ByteBufferList> callback) {
super(length);
if (length <= 0) throw new IllegalArgumentException("length should be > 0");
this.callback = callback;
}
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
callback.parsed(bb.get(length));
return null;
}
}
static class LenByteBufferListWaiter extends Waiter {
private final ParseCallback<ByteBufferList> callback;
public LenByteBufferListWaiter(ParseCallback<ByteBufferList> callback) {
super(4);
this.callback = callback;
}
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
int length = bb.getInt();
return new ByteBufferListWaiter(length, callback);
}
}
static class UntilWaiter extends Waiter {
byte value;
DataCallback callback;
public UntilWaiter(byte value, DataCallback callback) {
super(1);
this.value = value;
this.callback = callback;
}
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
boolean found = true;
ByteBufferList cb = new ByteBufferList();
while (bb.size() > 0) {
ByteBuffer b = bb.remove();
b.mark();
int index = 0;
while (b.remaining() > 0 && !(found = (b.get() == value))) {
index++;
}
b.reset();
if (found) {
bb.addFirst(b);
bb.get(cb, index);
// eat the one we're waiting on
bb.get();
break;
} else {
cb.add(b);
}
}
callback.onDataAvailable(emitter, cb);
if (found) {
return null;
} else {
return this;
}
}
}
private class TapWaiter extends Waiter {
private final TapCallback callback;
public TapWaiter(TapCallback callback) {
super(0);
this.callback = callback;
}
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
Method method = getTap(callback);
method.setAccessible(true);
try {
method.invoke(callback, args.toArray());
} catch (Exception e) {
Log.e("PushParser", "Error while invoking tap callback", e);
}
args.clear();
return null;
}
}
private Waiter noopArgWaiter = new Waiter(0) {
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
args.add(null);
return null;
}
};
private Waiter byteArgWaiter = new Waiter(1) {
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
args.add(bb.get());
return null;
}
};
private Waiter shortArgWaiter = new Waiter(2) {
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
args.add(bb.getShort());
return null;
}
};
private Waiter intArgWaiter = new Waiter(4) {
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
args.add(bb.getInt());
return null;
}
};
private Waiter longArgWaiter = new Waiter(8) {
@Override
public Waiter onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
args.add(bb.getLong());
return null;
}
};
private ParseCallback<byte[]> byteArrayArgCallback = new ParseCallback<byte[]>() {
@Override
public void parsed(byte[] data) {
args.add(data);
}
};
private ParseCallback<ByteBufferList> byteBufferListArgCallback = new ParseCallback<ByteBufferList>() {
@Override
public void parsed(ByteBufferList data) {
args.add(data);
}
};
private ParseCallback<byte[]> stringArgCallback = new ParseCallback<byte[]>() {
@Override
public void parsed(byte[] data) {
args.add(new String(data));
}
};
DataEmitter mEmitter;
private LinkedList<Waiter> mWaiting = new LinkedList<Waiter>();
private ArrayList<Object> args = new ArrayList<Object>();
ByteOrder order = ByteOrder.BIG_ENDIAN;
public PushParser setOrder(ByteOrder order) {
this.order = order;
return this;
}
public PushParser(DataEmitter s) {
mEmitter = s;
mEmitter.setDataCallback(this);
}
public PushParser readInt(ParseCallback<Integer> callback) {
mWaiting.add(new IntWaiter(callback));
return this;
}
public PushParser readByteArray(int length, ParseCallback<byte[]> callback) {
mWaiting.add(new ByteArrayWaiter(length, callback));
return this;
}
public PushParser readByteBufferList(int length, ParseCallback<ByteBufferList> callback) {
mWaiting.add(new ByteBufferListWaiter(length, callback));
return this;
}
public PushParser until(byte b, DataCallback callback) {
mWaiting.add(new UntilWaiter(b, callback));
return this;
}
public PushParser readByte() {
mWaiting.add(byteArgWaiter);
return this;
}
public PushParser readShort() {
mWaiting.add(shortArgWaiter);
return this;
}
public PushParser readInt() {
mWaiting.add(intArgWaiter);
return this;
}
public PushParser readLong() {
mWaiting.add(longArgWaiter);
return this;
}
public PushParser readByteArray(int length) {
return (length == -1) ? readLenByteArray() : readByteArray(length, byteArrayArgCallback);
}
public PushParser readLenByteArray() {
mWaiting.add(new LenByteArrayWaiter(byteArrayArgCallback));
return this;
}
public PushParser readByteBufferList(int length) {
return (length == -1) ? readLenByteBufferList() : readByteBufferList(length, byteBufferListArgCallback);
}
public PushParser readLenByteBufferList() {
return readLenByteBufferList(byteBufferListArgCallback);
}
public PushParser readLenByteBufferList(ParseCallback<ByteBufferList> callback) {
mWaiting.add(new LenByteBufferListWaiter(callback));
return this;
}
public PushParser readString() {
mWaiting.add(new LenByteArrayWaiter(stringArgCallback));
return this;
}
public PushParser noop() {
mWaiting.add(noopArgWaiter);
return this;
}
ByteBufferList pending = new ByteBufferList();
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
bb.get(pending);
while (mWaiting.size() > 0 && pending.remaining() >= mWaiting.peek().length) {
pending.order(order);
Waiter next = mWaiting.poll().onDataAvailable(emitter, pending);
if (next != null) mWaiting.addFirst(next);
}
if (mWaiting.size() == 0)
pending.get(bb);
}
public void tap(TapCallback callback) {
mWaiting.add(new TapWaiter(callback));
}
static Hashtable<Class, Method> mTable = new Hashtable<Class, Method>();
static Method getTap(TapCallback callback) {
Method found = mTable.get(callback.getClass());
if (found != null)
return found;
for (Method method : callback.getClass().getMethods()) {
if ("tap".equals(method.getName())) {
mTable.put(callback.getClass(), method);
return method;
}
}
// try the proguard friendly route, take the first/only method
// in case "tap" has been renamed
Method[] candidates = callback.getClass().getDeclaredMethods();
if (candidates.length == 1)
return candidates[0];
String fail =
"-keep class * extends com.koushikdutta.async.TapCallback {\n" +
" *;\n" +
"}\n";
//null != "AndroidAsync: tap callback could not be found. Proguard? Use this in your proguard config:\n" + fail;
throw new AssertionError(fail);
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/SelectorWrapper.java
================================================
package com.koushikdutta.async;
import java.io.Closeable;
import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.util.Set;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Created by koush on 2/13/14.
*/
class SelectorWrapper implements Closeable {
private Selector selector;
public AtomicBoolean isWaking = new AtomicBoolean(false);
Semaphore semaphore = new Semaphore(0);
public Selector getSelector() {
return selector;
}
public SelectorWrapper(Selector selector) {
this.selector = selector;
}
public int selectNow() throws IOException {
return selector.selectNow();
}
public void select() throws IOException {
select(0);
}
public void select(long timeout) throws IOException {
try {
semaphore.drainPermits();
selector.select(timeout);
}
finally {
semaphore.release(Integer.MAX_VALUE);
}
}
public Set<SelectionKey> keys() {
return selector.keys();
}
public Set<SelectionKey> selectedKeys() {
return selector.selectedKeys();
}
@Override
public void close() throws IOException {
selector.close();
}
public boolean isOpen() {
return selector.isOpen();
}
public void wakeupOnce() {
// see if it is selecting, ie, can't acquire a permit
boolean selecting = !semaphore.tryAcquire();
selector.wakeup();
// if it was selecting, then the wakeup definitely worked.
if (selecting)
return;
// now, we NEED to wait for the select to start to forcibly wake it.
if (isWaking.getAndSet(true)) {
selector.wakeup();
return;
}
try {
waitForSelect();
selector.wakeup();
} finally {
isWaking.set(false);
}
}
public boolean waitForSelect() {
// try to wake up 10 times
for (int i = 0; i < 100; i++) {
try {
if (semaphore.tryAcquire(10, TimeUnit.MILLISECONDS)) {
// successfully acquiring means the selector is NOT selecting, since select
// will drain all permits.
continue;
}
} catch (InterruptedException e) {
// an InterruptedException means the acquire failed a select is in progress,
// since it holds all permits
return true;
}
}
return false;
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java
================================================
package com.koushikdutta.async;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
class ServerSocketChannelWrapper extends ChannelWrapper {
ServerSocketChannel mChannel;
@Override
public void shutdownOutput() {
}
@Override
public void shutdownInput() {
}
@Override
public InetAddress getLocalAddress() {
return mChannel.socket().getInetAddress();
}
@Override
public int getLocalPort() {
return mChannel.socket().getLocalPort();
}
ServerSocketChannelWrapper(ServerSocketChannel channel) throws IOException {
super(channel);
mChannel = channel;
}
@Override
public int read(ByteBuffer buffer) throws IOException {
final String msg = "Can't read ServerSocketChannel";
throw new IOException(msg);
}
@Override
public boolean isConnected() {
return false;
}
@Override
public int write(ByteBuffer src) throws IOException {
final String msg = "Can't write ServerSocketChannel";
throw new IOException(msg);
}
@Override
public SelectionKey register(Selector sel) throws ClosedChannelException {
return mChannel.register(sel, SelectionKey.OP_ACCEPT);
}
@Override
public int write(ByteBuffer[] src) throws IOException {
final String msg = "Can't write ServerSocketChannel";
throw new IOException(msg);
}
@Override
public long read(ByteBuffer[] byteBuffers) throws IOException {
final String msg = "Can't read ServerSocketChannel";
throw new IOException(msg);
}
@Override
public long read(ByteBuffer[] byteBuffers, int i, int i2) throws IOException {
final String msg = "Can't read ServerSocketChannel";
throw new IOException(msg);
}
@Override
public Object getSocket() {
return mChannel.socket();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java
================================================
package com.koushikdutta.async;
import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
class SocketChannelWrapper extends ChannelWrapper {
SocketChannel mChannel;
@Override
public InetAddress getLocalAddress() {
return mChannel.socket().getLocalAddress();
}
@Override
public int getLocalPort() {
return mChannel.socket().getLocalPort();
}
SocketChannelWrapper(SocketChannel channel) throws IOException {
super(channel);
mChannel = channel;
}
@Override
public int read(ByteBuffer buffer) throws IOException {
return mChannel.read(buffer);
}
@Override
public boolean isConnected() {
return mChannel.isConnected();
}
@Override
public int write(ByteBuffer src) throws IOException {
return mChannel.write(src);
}
@Override
public int write(ByteBuffer[] src) throws IOException {
return (int)mChannel.write(src);
}
@Override
public SelectionKey register(Selector sel) throws ClosedChannelException {
return register(sel, SelectionKey.OP_CONNECT);
}
@Override
public void shutdownOutput() {
try {
mChannel.socket().shutdownOutput();
}
catch (Exception e) {
}
}
@Override
public void shutdownInput() {
try {
mChannel.socket().shutdownInput();
}
catch (Exception e) {
}
}
@Override
public long read(ByteBuffer[] byteBuffers) throws IOException {
return mChannel.read(byteBuffers);
}
@Override
public long read(ByteBuffer[] byteBuffers, int i, int i2) throws IOException {
return mChannel.read(byteBuffers, i, i2);
}
@Override
public Object getSocket() {
return mChannel.socket();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/TapCallback.java
================================================
package com.koushikdutta.async;
public interface TapCallback {
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/ThreadQueue.java
================================================
package com.koushikdutta.async;
import java.util.LinkedList;
import java.util.WeakHashMap;
import java.util.concurrent.Semaphore;
class ThreadQueue extends LinkedList<Runnable> {
final private static WeakHashMap<Thread, ThreadQueue> mThreadQueues = new WeakHashMap<Thread, ThreadQueue>();
static ThreadQueue getOrCreateThreadQueue(Thread thread) {
ThreadQueue queue;
synchronized (mThreadQueues) {
queue = mThreadQueues.get(thread);
if (queue == null) {
queue = new ThreadQueue();
mThreadQueues.put(thread, queue);
}
}
return queue;
}
static void release(AsyncSemaphore semaphore) {
synchronized (mThreadQueues) {
for (ThreadQueue threadQueue: mThreadQueues.values()) {
if (threadQueue.waiter == semaphore)
threadQueue.queueSemaphore.release();
}
}
}
AsyncSemaphore waiter;
Semaphore queueSemaphore = new Semaphore(0);
@Override
public boolean add(Runnable object) {
synchronized (this) {
return super.add(object);
}
}
@Override
public boolean remove(Object object) {
synchronized (this) {
return super.remove(object);
}
}
@Override
public Runnable remove() {
synchronized (this) {
if (this.isEmpty())
return null;
return super.remove();
}
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/Util.java
================================================
package com.koushikdutta.async;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.DataCallback;
import com.koushikdutta.async.callback.WritableCallback;
import com.koushikdutta.async.util.Allocator;
import com.koushikdutta.async.util.StreamUtility;
import com.koushikdutta.async.wrapper.AsyncSocketWrapper;
import com.koushikdutta.async.wrapper.DataEmitterWrapper;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
public class Util {
public static boolean SUPRESS_DEBUG_EXCEPTIONS = false;
public static void emitAllData(DataEmitter emitter, ByteBufferList list) {
int remaining;
DataCallback handler = null;
while (!emitter.isPaused() && (handler = emitter.getDataCallback()) != null && (remaining = list.remaining()) > 0) {
handler.onDataAvailable(emitter, list);
if (remaining == list.remaining() && handler == emitter.getDataCallback() && !emitter.isPaused()) {
// this is generally indicative of failure...
// 1) The data callback has not changed
// 2) no data was consumed
// 3) the data emitter was not paused
// call byteBufferList.recycle() or read all the data to prevent this assertion.
// this is nice to have, as it identifies protocol or parsing errors.
// System.out.println("Data: " + list.peekString());
System.out.println("handler: " + handler);
list.recycle();
if (SUPRESS_DEBUG_EXCEPTIONS)
return;
throw new RuntimeException("mDataHandler failed to consume data, yet remains the mDataHandler.");
}
}
if (list.remaining() != 0 && !emitter.isPaused()) {
// not all the data was consumed...
// call byteBufferList.recycle() or read all the data to prevent this assertion.
// this is nice to have, as it identifies protocol or parsing errors.
// System.out.println("Data: " + list.peekString());
System.out.println("handler: " + handler);
System.out.println("emitter: " + emitter);
list.recycle();
if (SUPRESS_DEBUG_EXCEPTIONS)
return;
// throw new AssertionError("Not all data was consumed by Util.emitAllData");
}
}
public static void pump(final InputStream is, final DataSink ds, final CompletedCallback callback) {
pump(is, Integer.MAX_VALUE, ds, callback);
}
public static void pump(final InputStream is, final long max, final DataSink ds, final CompletedCallback callback) {
final CompletedCallback wrapper = new CompletedCallback() {
boolean reported;
@Override
public void onCompleted(Exception ex) {
if (reported)
return;
reported = true;
callback.onCompleted(ex);
}
};
final WritableCallback cb = new WritableCallback() {
int totalRead = 0;
private void cleanup() {
ds.setClosedCallback(null);
ds.setWriteableCallback(null);
pending.recycle();
StreamUtility.closeQuietly(is);
}
ByteBufferList pending = new ByteBufferList();
Allocator allocator = new Allocator().setMinAlloc((int)Math.min(2 << 19, max));
@Override
public void onWriteable() {
try {
do {
if (!pending.hasRemaining()) {
ByteBuffer b = allocator.allocate();
long toRead = Math.min(max - totalRead, b.capacity());
int read = is.read(b.array(), 0, (int)toRead);
if (read == -1 || totalRead == max) {
cleanup();
wrapper.onCompleted(null);
return;
}
allocator.track(read);
totalRead += read;
b.position(0);
b.limit(read);
pending.add(b);
}
ds.write(pending);
}
while (!pending.hasRemaining());
}
catch (Exception e) {
cleanup();
wrapper.onCompleted(e);
}
}
};
ds.setWriteableCallback(cb);
ds.setClosedCallback(wrapper);
cb.onWriteable();
}
public static void pump(final DataEmitter emitter, final DataSink sink, final CompletedCallback callback) {
final DataCallback dataCallback = new DataCallback() {
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
sink.write(bb);
if (bb.remaining() > 0)
emitter.pause();
}
};
emitter.setDataCallback(dataCallback);
sink.setWriteableCallback(new WritableCallback() {
@Override
public void onWriteable() {
emitter.resume();
}
});
final CompletedCallback wrapper = new CompletedCallback() {
boolean reported;
@Override
public void onCompleted(Exception ex) {
if (reported)
return;
reported = true;
emitter.setDataCallback(null);
emitter.setEndCallback(null);
sink.setClosedCallback(null);
sink.setWriteableCallback(null);
callback.onCompleted(ex);
}
};
emitter.setEndCallback(wrapper);
sink.setClosedCallback(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
if (ex == null)
ex = new IOException("sink was closed before emitter ended");
wrapper.onCompleted(ex);
}
});
}
public static void stream(AsyncSocket s1, AsyncSocket s2, CompletedCallback callback) {
pump(s1, s2, callback);
pump(s2, s1, callback);
}
public static void pump(final File file, final DataSink ds, final CompletedCallback callback) {
try {
if (file == null || ds == null) {
callback.onCompleted(null);
return;
}
final InputStream is = new FileInputStream(file);
pump(is, ds, new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
try {
is.close();
callback.onCompleted(ex);
}
catch (IOException e) {
callback.onCompleted(e);
}
}
});
}
catch (Exception e) {
callback.onCompleted(e);
}
}
public static void writeAll(final DataSink sink, final ByteBufferList bb, final CompletedCallback callback) {
WritableCallback wc;
sink.setWriteableCallback(wc = new WritableCallback() {
@Override
public void onWriteable() {
sink.write(bb);
if (bb.remaining() == 0 && callback != null) {
sink.setWriteableCallback(null);
callback.onCompleted(null);
}
}
});
wc.onWriteable();
}
public static void writeAll(DataSink sink, byte[] bytes, CompletedCallback callback) {
ByteBuffer bb = ByteBufferList.obtain(bytes.length);
bb.put(bytes);
bb.flip();
ByteBufferList bbl = new ByteBufferList();
bbl.add(bb);
writeAll(sink, bbl, callback);
}
public static <T extends AsyncSocket> T getWrappedSocket(AsyncSocket socket, Class<T> wrappedClass) {
if (wrappedClass.isInstance(socket))
return (T)socket;
while (socket instanceof AsyncSocketWrapper) {
socket = ((AsyncSocketWrapper)socket).getSocket();
if (wrappedClass.isInstance(socket))
return (T)socket;
}
return null;
}
public static DataEmitter getWrappedDataEmitter(DataEmitter emitter, Class wrappedClass) {
if (wrappedClass.isInstance(emitter))
return emitter;
while (emitter instanceof DataEmitterWrapper) {
emitter = ((AsyncSocketWrapper)emitter).getSocket();
if (wrappedClass.isInstance(emitter))
return emitter;
}
return null;
}
public static void end(DataEmitter emitter, Exception e) {
if (emitter == null)
return;
end(emitter.getEndCallback(), e);
}
public static void end(CompletedCallback end, Exception e) {
if (end != null)
end.onCompleted(e);
}
public static void writable(DataSink emitter) {
if (emitter == null)
return;
writable(emitter.getWriteableCallback());
}
public static void writable(WritableCallback writable) {
if (writable != null)
writable.onWriteable();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/ZipDataSink.java
================================================
package com.koushikdutta.async;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import com.koushikdutta.async.callback.CompletedCallback;
public class ZipDataSink extends FilteredDataSink {
public ZipDataSink(DataSink sink) {
super(sink);
}
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ZipOutputStream zop = new ZipOutputStream(bout);
public void putNextEntry(ZipEntry ze) throws IOException {
zop.putNextEntry(ze);
}
public void closeEntry() throws IOException {
zop.closeEntry();
}
protected void report(Exception e) {
CompletedCallback closed = getClosedCallback();
if (closed != null)
closed.onCompleted(e);
}
@Override
public void end() {
try {
zop.close();
}
catch (IOException e) {
report(e);
return;
}
setMaxBuffer(Integer.MAX_VALUE);
write(new ByteBufferList());
super.end();
}
@Override
public ByteBufferList filter(ByteBufferList bb) {
try {
if (bb != null) {
while (bb.size() > 0) {
ByteBuffer b = bb.remove();
ByteBufferList.writeOutputStream(zop, b);
ByteBufferList.reclaim(b);
}
}
ByteBufferList ret = new ByteBufferList(bout.toByteArray());
bout.reset();
return ret;
}
catch (IOException e) {
report(e);
return null;
}
finally {
if (bb != null)
bb.recycle();
}
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/CompletedCallback.java
================================================
package com.koushikdutta.async.callback;
public interface CompletedCallback {
public class NullCompletedCallback implements CompletedCallback {
@Override
public void onCompleted(Exception ex) {
}
}
public void onCompleted(Exception ex);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ConnectCallback.java
================================================
package com.koushikdutta.async.callback;
import com.koushikdutta.async.AsyncSocket;
public interface ConnectCallback {
public void onConnectCompleted(Exception ex, AsyncSocket socket);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ContinuationCallback.java
================================================
package com.koushikdutta.async.callback;
import com.koushikdutta.async.future.Continuation;
public interface ContinuationCallback {
public void onContinue(Continuation continuation, CompletedCallback next) throws Exception;
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/DataCallback.java
================================================
package com.koushikdutta.async.callback;
import com.koushikdutta.async.ByteBufferList;
import com.koushikdutta.async.DataEmitter;
public interface DataCallback {
public class NullDataCallback implements DataCallback {
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
bb.recycle();
}
}
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ListenCallback.java
================================================
package com.koushikdutta.async.callback;
import com.koushikdutta.async.AsyncServerSocket;
import com.koushikdutta.async.AsyncSocket;
public interface ListenCallback extends CompletedCallback {
public void onAccepted(AsyncSocket socket);
public void onListening(AsyncServerSocket socket);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ResultCallback.java
================================================
package com.koushikdutta.async.callback;
public interface ResultCallback<S, T> {
public void onCompleted(Exception e, S source, T result);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/SocketCreateCallback.java
================================================
package com.koushikdutta.async.callback;
import com.koushikdutta.async.AsyncNetworkSocket;
public interface SocketCreateCallback {
void onSocketCreated(int localPort);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ValueCallback.java
================================================
package com.koushikdutta.async.callback;
/**
* Created by koush on 7/5/16.
*/
public interface ValueCallback<T> {
void onResult(T value);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ValueFunction.java
================================================
package com.koushikdutta.async.callback;
public interface ValueFunction<T> {
T getValue() throws Exception;
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/callback/WritableCallback.java
================================================
package com.koushikdutta.async.callback;
public interface WritableCallback {
public void onWriteable();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/dns/Dns.java
================================================
package com.koushikdutta.async.dns;
import com.koushikdutta.async.AsyncDatagramSocket;
import com.koushikdutta.async.AsyncServer;
import com.koushikdutta.async.ByteBufferList;
import com.koushikdutta.async.DataEmitter;
import com.koushikdutta.async.callback.DataCallback;
import com.koushikdutta.async.future.Cancellable;
import com.koushikdutta.async.future.Future;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.async.future.SimpleFuture;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Random;
/**
* Created by koush on 10/20/13.
*/
public class Dns {
public static Future<DnsResponse> lookup(String host) {
return lookup(AsyncServer.getDefault(), host, false, null);
}
private static int setFlag(int flags, int value, int offset) {
return flags | (value << offset);
}
private static int setQuery(int flags) {
return setFlag(flags, 0, 0);
}
private static int setRecursion(int flags) {
return setFlag(flags, 1, 8);
}
private static void addName(ByteBuffer bb, String name) {
String[] parts = name.split("\\.");
for (String part: parts) {
bb.put((byte)part.length());
bb.put(part.getBytes());
}
bb.put((byte)0);
}
public static Future<DnsResponse> lookup(AsyncServer server, String host) {
return lookup(server, host, false, null);
}
public static Cancellable multicastLookup(AsyncServer server, String host, FutureCallback<DnsResponse> callback) {
return lookup(server, host, true, callback);
}
public static Cancellable multicastLookup(String host, FutureCallback<DnsResponse> callback) {
return multicastLookup(AsyncServer.getDefault(), host, callback);
}
public static Future<DnsResponse> lookup(AsyncServer server, String host, final boolean multicast, final FutureCallback<DnsResponse> callback) {
if (!server.isAffinityThread()) {
SimpleFuture<DnsResponse> ret = new SimpleFuture<>();
server.post(() -> ret.setComplete(lookup(server, host, multicast, callback)));
return ret;
}
ByteBuffer packet = ByteBufferList.obtain(1024).order(ByteOrder.BIG_ENDIAN);
short id = (short)new Random().nextInt();
short flags = (short)setQuery(0);
if (!multicast)
flags = (short)setRecursion(flags);
packet.putShort(id);
packet.putShort(flags);
// number questions
packet.putShort(multicast ? (short)1 : (short)2);
// number answer rr
packet.putShort((short)0);
// number authority rr
packet.putShort((short)0);
// number additional rr
packet.putShort((short)0);
addName(packet, host);
// query
packet.putShort(multicast ? (short)12 : (short)1);
// request internet address
packet.putShort((short)1);
if (!multicast) {
addName(packet, host);
// AAAA query
packet.putShort((short) 28);
// request internet address
packet.putShort((short)1);
}
packet.flip();
try {
final AsyncDatagramSocket dgram;
// todo, use the dns server...
if (!multicast) {
dgram = server.connectDatagram(new InetSocketAddress("8.8.8.8", 53));
}
else {
// System.out.println("multicast dns...");
dgram = AsyncServer.getDefault().openDatagram(null, 0, true);
Field field = DatagramSocket.class.getDeclaredField("impl");
field.setAccessible(true);
Object impl = field.get(dgram.getSocket());
Method method = impl.getClass().getDeclaredMethod("join", InetAddress.class);
method.setAccessible(true);
method.invoke(impl, InetAddress.getByName("224.0.0.251"));
((DatagramSocket)dgram.getSocket()).setBroadcast(true);
}
final SimpleFuture<DnsResponse> ret = new SimpleFuture<DnsResponse>() {
@Override
protected void cleanup() {
super.cleanup();
// System.out.println("multicast dns cleanup...");
dgram.close();
}
};
dgram.setDataCallback(new DataCallback() {
@Override
public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) {
try {
// System.out.println(dgram.getRemoteAddress());
DnsResponse response = DnsResponse.parse(bb);
// System.out.println(response);
response.source = dgram.getRemoteAddress();
if (!multicast) {
dgram.close();
ret.setComplete(response);
}
else {
callback.onCompleted(null, response);
}
}
catch (Exception e) {
}
bb.recycle();
}
});
if (!multicast)
dgram.write(new ByteBufferList(packet));
else
dgram.send(new InetSocketAddress("224.0.0.251", 5353), packet);
return ret;
}
catch (Exception e) {
SimpleFuture<DnsResponse> ret = new SimpleFuture<DnsResponse>();
ret.setComplete(e);
if (multicast)
callback.onCompleted(e, null);
return ret;
}
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/dns/DnsResponse.java
================================================
package com.koushikdutta.async.dns;
import com.koushikdutta.async.ByteBufferList;
import com.koushikdutta.async.http.Multimap;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
/**
* Created by koush on 10/20/13.
*/
public class DnsResponse {
public ArrayList<InetAddress> addresses = new ArrayList<InetAddress>();
public ArrayList<String> names = new ArrayList<String>();
public Multimap txt = new Multimap();
public InetSocketAddress source;
private static String parseName(ByteBufferList bb, ByteBuffer backReference) {
bb.order(ByteOrder.BIG_ENDIAN);
String ret = "";
int len;
while (0 != (len = bb.get() & 0x00FF)) {
// compressed
if ((len & 0x00c0) == 0x00c0) {
int offset = ((len & ~0xFFFFFFc0) << 8) | (bb.get() & 0x00FF);
if (ret.length() > 0)
ret += ".";
ByteBufferList sub = new ByteBufferList();
ByteBuffer duplicate = backReference.duplicate();
duplicate.get(new byte[offset]);
sub.add(duplicate);
return ret + parseName(sub, backReference);
}
byte[] bytes = new byte[len];
bb.get(bytes);
if (ret.length() > 0)
ret += ".";
ret += new String(bytes);
}
return ret;
}
public static DnsResponse parse(ByteBufferList bb) {
ByteBuffer b = bb.getAll();
bb.add(b.duplicate());
// naive parsing...
bb.order(ByteOrder.BIG_ENDIAN);
// id
bb.getShort();
// flags
bb.getShort();
// number questions
int questions = bb.getShort();
// number answer rr
int answers = bb.getShort();
// number authority rr
int authorities = bb.getShort();
// number additional rr
int additionals = bb.getShort();
for (int i = 0; i < questions; i++) {
parseName(bb, b);
// type
bb.getShort();
// class
bb.getShort();
}
DnsResponse response = new DnsResponse();
for (int i = 0; i < answers; i++) {
String name = parseName(bb, b);
// type
int type = bb.getShort();
// class
int clazz = bb.getShort();
// ttl
int ttl = bb.getInt();
// length of address
int length = bb.getShort();
try {
if (type == 1) {
// data
byte[] data = new byte[length];
bb.get(data);
response.addresses.add(InetAddress.getByAddress(data));
}
else if (type == 0x000c) {
response.names.add(parseName(bb, b));
}
else if (type == 16) {
ByteBufferList txt = new ByteBufferList();
bb.get(txt, length);
response.parseTxt(txt);
}
else {
bb.get(new byte[length]);
}
}
catch (Exception e) {
// e.printStackTrace();
}
}
// authorities
for (int i = 0; i < authorities; i++) {
String name = parseName(bb, b);
// type
int type = bb.getShort();
// class
int clazz = bb.getShort();
// ttl
int ttl = bb.getInt();
// length of address
int length = bb.getShort();
try {
bb.get(new byte[length]);
}
catch (Exception e) {
// e.printStackTrace();
}
}
// additionals
for (int i = 0; i < additionals; i++) {
String name = parseName(bb, b);
// type
int type = bb.getShort();
// class
int clazz = bb.getShort();
// ttl
int ttl = bb.getInt();
// length of address
int length = bb.getShort();
try {
if (type == 16) {
ByteBufferList txt = new ByteBufferList();
bb.get(txt, length);
response.parseTxt(txt);
}
else {
bb.get(new byte[length]);
}
}
catch (Exception e) {
// e.printStackTrace();
}
}
return response;
}
void parseTxt(ByteBufferList bb) {
while (bb.hasRemaining()) {
int length = (int)bb.get() & 0x00FF;
byte [] bytes = new byte[length];
bb.get(bytes);
String string = new String(bytes);
String[] pair = string.split("=");
txt.add(pair[0], pair[1]);
}
}
@Override
public String toString() {
String ret = "addresses:\n";
for (InetAddress address: addresses)
ret += address.toString() + "\n";
ret += "names:\n";
for (String name: names)
ret += name + "\n";
return ret;
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/Cancellable.java
================================================
package com.koushikdutta.async.future;
public interface Cancellable {
/**
* Check whether this asynchronous operation completed successfully.
* @return
*/
boolean isDone();
/**
* Check whether this asynchronous operation has been cancelled.
* @return
*/
boolean isCancelled();
/**
* Attempt to cancel this asynchronous operation.
* @return The return value is whether the operation cancelled successfully.
*/
boolean cancel();
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/Continuation.java
================================================
package com.koushikdutta.async.future;
import com.koushikdutta.async.callback.CompletedCallback;
import com.koushikdutta.async.callback.ContinuationCallback;
import java.util.LinkedList;
public class Continuation extends SimpleCancellable implements ContinuationCallback, Runnable, Cancellable {
CompletedCallback callback;
Runnable cancelCallback;
public CompletedCallback getCallback() {
return callback;
}
public void setCallback(CompletedCallback callback) {
this.callback = callback;
}
public Runnable getCancelCallback() {
return cancelCallback;
}
public void setCancelCallback(Runnable cancelCallback) {
this.cancelCallback = cancelCallback;
}
public void setCancelCallback(final Cancellable cancel) {
if (cancel == null) {
this.cancelCallback = null;
return;
}
this.cancelCallback = new Runnable() {
@Override
public void run() {
cancel.cancel();
}
};
}
public Continuation() {
this(null);
}
public Continuation(CompletedCallback callback) {
this(callback, null);
}
public Continuation(CompletedCallback callback, Runnable cancelCallback) {
this.cancelCallback = cancelCallback;
this.callback = callback;
}
private CompletedCallback wrap() {
return new CompletedCallback() {
boolean mThisCompleted;
@Override
public void onCompleted(Exception ex) {
// onCompleted may be called more than once... buggy code.
// only accept the first (timeouts, etc)
if (mThisCompleted)
return;
mThisCompleted = true;
waiting = false;
if (ex == null) {
next();
return;
}
reportCompleted(ex);
}
};
}
void reportCompleted(Exception ex) {
if (!setComplete())
return;
if (callback != null)
callback.onCompleted(ex);
}
LinkedList<ContinuationCallback> mCallbacks = new LinkedList<ContinuationCallback>();
private ContinuationCallback hook(ContinuationCallback callback) {
if (callback instanceof DependentCancellable) {
DependentCancellable child = (DependentCancellable)callback;
child.setParent(this);
}
return callback;
}
public Continuation add(ContinuationCallback callback) {
mCallbacks.add(hook(callback));
return this;
}
public Continuation insert(ContinuationCallback callback) {
mCallbacks.add(0, hook(callback));
return this;
}
public Continuation add(final DependentFuture future) {
future.setParent(this);
add(new ContinuationCallback() {
@Override
public void onContinue(Continuation continuation, CompletedCallback next) throws Exception {
future.get();
next.onCompleted(null);
}
});
return this;
}
private boolean inNext;
private boolean waiting;
private void next() {
if (inNext)
return;
while (mCallbacks.size() > 0 && !waiting && !isDone() && !isCancelled()) {
ContinuationCallback cb = mCallbacks.remove();
try {
inNext = true;
waiting = true;
cb.onContinue(this, wrap());
}
catch (Exception e) {
reportCompleted(e);
}
finally {
inNext = false;
}
}
if (waiting)
return;
if (isDone())
return;
if (isCancelled())
return;
reportCompleted(null);
}
@Override
public boolean cancel() {
if (!super.cancel())
return false;
if (cancelCallback != null)
cancelCallback.run();
return true;
}
boolean started;
public Continuation start() {
if (started)
throw new IllegalStateException("already started");
started = true;
next();
return this;
}
@Override
public void onContinue(Continuation continuation, CompletedCallback next) throws Exception {
setCallback(next);
start();
}
@Override
public void run() {
start();
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/Converter.java
================================================
package com.koushikdutta.async.future;
import android.text.TextUtils;
import com.koushikdutta.async.ByteBufferList;
import org.json.JSONObject;
import java.io.InvalidObjectException;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
public class Converter<R> {
public static <T> Converter<T> convert(Future<T> future, String mime) {
return new Converter<>(future, mime);
}
public static <T> Converter<T> convert(Future<T> future) {
return convert(future, null);
}
static class MimedData<T> {
public MimedData(T data, String mime) {
this.data = data;
this.mime = mime;
}
T data;
String mime;
}
static class MultiTransformer<T, F> extends MultiTransformFuture<MimedData<Future<T>>, MimedData<Future<F>>> {
TypeConverter<T, F> converter;
String converterMime;
int distance;
public MultiTransformer(TypeConverter<T, F> converter, String converterMime, int distance) {
this.converter = converter;
this.converterMime = converterMime;
this.distance = distance;
}
@Override
protected void transform(MimedData<Future<F>> converting) {
// transform will only ever be called once, and is called immediately,
// the transform is on the future itself, and not a pending value.
// so there's no risk of running the converter twice.
final String mime = converting.mime;
// this future will receive the eventual actual value.
final MultiFuture<T> converted = new MultiFuture<>();
// this marks the conversion as "complete". the conversion will start
// as soon as the value is ready.
setComplete(new MimedData<>(converted, mimeReplace(mime, converterMime)));
// wait on the incoming value and convert it
converting.data.thenConvert(data -> converter.convert(data, mime)).
setCallback((e, result1) -> {
if (e != null)
converted.setComplete(e);
else
converted.setComplete(result1);
});
}
}
static abstract class EnsureHashMap<K, V> extends LinkedHashMap<K, V> {
synchronized V ensure(K k) {
if (!containsKey(k)) {
put(k, makeDefault());
}
return get(k);
}
protected abstract V makeDefault();
}
static class MimedType<T> {
MimedType(Class<T> type, String mime) {
this.type = type;
this.mime = mime;
}
Class<T> type;
String mime;
@Override
public int hashCode() {
return type.hashCode() ^ mime.hashCode();
}
@Override
public boolean equals(Object obj) {
MimedType other = (MimedType)obj;
return type.equals(other.type) && mime.equals(other.mime);
}
// check if this mimed type is the same or more specific than this mimed type
public boolean isTypeOf(MimedType other) {
// check the type, this type must be less specific than the other type
if (!this.type.isAssignableFrom(other.type))
return false;
return isTypeOf(other.mime);
}
public String primary() {
return mime.split("/")[0];
}
public String secondary() {
return mime.split("/")[1];
}
// check if this mimed type is convertible to another mimed type
public boolean isTypeOf(String mime) {
String[] otherParts = mime.split("/");
String[] myParts = this.mime.split("/");
// ensure the other type is the same OR this type is fine with a wildcard
if (!"*".equals(myParts[0]) && !otherParts[0].equals(myParts[0]))
return false;
if (!"*".equals(myParts[1]) && !otherParts[1].equals(myParts[1]))
return false;
return true;
}
@Override
public String toString() {
return type.getSimpleName() + " " + mime;
}
}
static class ConverterTransformers<F, T> extends LinkedHashMap<MimedType<T>, MultiTransformer<T, F>> {
}
static class Converters<F, T> extends EnsureHashMap<MimedType<F>, ConverterTransformers<F, T>> {
@Override
protected ConverterTransformers makeDefault() {
return new ConverterTransformers();
}
private static <F, T> void add(ConverterTransformers<F, T> set, ConverterTransformers<F, T> more) {
if (more == null)
return;
set.putAll(more);
}
public ConverterTransformers<F, T> getAll(MimedType<T> mimedType) {
ConverterTransformers<F, T> ret = new ConverterTransformers<>();
for (MimedType candidate: keySet()) {
if (candidate.isTypeOf(mimedType))
add(ret, get(candidate));
}
return ret;
}
}
Converters<Object, Object> outputs;
protected ConverterEntries getConverters() {
return new ConverterEntries(Converters);
}
MultiFuture<R> future = new MultiFuture<>();
String futureMime;
protected Converter(Future future, String mime) {
if (TextUtils.isEmpty(mime))
mime = MIME_ALL;
this.futureMime = mime;
this.future.setComplete(future);
}
synchronized private final <T> Future<T> to(Object value, Class<T> clazz, String mime) {
if (clazz.isInstance(value))
return new SimpleFuture<>((T) value);
return to(value.getClass(), clazz, mime);
}
synchronized private final <T> Future<T> to(Class fromClass, Class<T> clazz, String mime) {
if (TextUtils.isEmpty(mime))
mime = MIME_ALL;
if (outputs == null) {
outputs = new Converters<>();
ConverterEntries converters = getConverters();
for (ConverterEntry entry: converters.list) {
outputs.ensure(entry.from).put(entry.to, new MultiTransformer<>(entry.typeConverter, entry.to.mime, entry.distance));
}
}
MimedType<T> target = new MimedType<>(clazz, mime);
ArrayDeque<PathInfo> bestMatch = new ArrayDeque<>();
ArrayDeque<PathInfo> currentPath = new ArrayDeque<>();
if (search(target, bestMatch, currentPath, new MimedType(fromClass, futureMime), new HashSet<MimedType>())) {
PathInfo current = bestMatch.removeFirst();
new SimpleFuture<>(new MimedData<>((Future<Object>)future, futureMime)).setCallback(current.transformer);
while (!bestMatch.isEmpty()) {
PathInfo next = bestMatch.removeFirst();
current.transformer.setCallback(next.transformer);
current = next;
}
return ((MultiTransformer<T, Object>)current.transformer).then(from -> from.data);
}
return new SimpleFuture<>(new InvalidObjectException("unable to find converter"));
}
static class PathInfo {
MultiTransformer<Object, Object> transformer;
String mime;
MimedType candidate;
static int distance(ArrayDeque<PathInfo> path) {
int distance = 0;
for (PathInfo entry: path) {
distance += entry.transformer.distance;
}
return distance;
}
}
static String mimeReplace(String mime1, String mime2) {
String[] parts = mime2.split("/");
String[] myParts = mime1.split("/");
// a wildcard mime converter adopts the mime of the converted type
String primary = !"*".equals(parts[0]) ? parts[0] : myParts[0];
String secondary = !"*".equals(parts[1]) ? parts[1] : myParts[1];
return primary + "/" + secondary;
}
public final <T> Future<T> to(Class<T> clazz) {
return to(clazz, null);
}
private <T> boolean search(MimedType<T> target, ArrayDeque<PathInfo> bestMatch, ArrayDeque<PathInfo> currentPath, MimedType currentSearch, HashSet<MimedType> searched) {
if (target.isTypeOf(currentSearch)) {
bestMatch.clear();
bestMatch.addAll(currentPath);
return true;
}
// the current path must have potential to be better than the best match
if (!bestMatch.isEmpty() && PathInfo.distance(currentPath) >= PathInfo.distance(bestMatch))
return false;
// prevent reentrancy
if (searched.contains(currentSearch))
return false;
boolean found = false;
searched.add(currentSearch);
ConverterTransformers<Object, Object> converterTransformers = outputs.getAll(currentSearch);
for (MimedType candidate: converterTransformers.keySet()) {
// this simulates the mime results of a transform
MimedType newSearch = new MimedType(candidate.type, mimeReplace(currentSearch.mime, candidate.mime));
PathInfo path = new PathInfo();
path.transformer = converterTransformers.get(candidate);
path.mime = newSearch.mime;
path.candidate = candidate;
currentPath.addLast(path);
try {
found |= search(target, bestMatch, currentPath, newSearch, searched);
}
finally {
currentPath.removeLast();
}
}
if (found) {
// if this resulted in a success,
// clear this from the currentSearch list, because we know this leads
// to a potential solution. maybe we can arrive here faster.
searched.remove(currentSearch);
}
return found;
}
private static final String MIME_ALL = "*/*";
public <T> Future<T> to(Class<T> clazz, String mime) {
return future.then(from -> to(from, clazz, mime));
}
static class ConverterEntry<F, T> {
ConverterEntry(Class<F> from, String fromMime, Class<T> to, String toMime, int distance, TypeConverter<T, F> typeConverter) {
this.from = new MimedType<>(from, fromMime);
this.to = new MimedType<>(to, toMime);
this.distance = distance;
this.typeConverter = typeConverter;
}
MimedType<F> from;
MimedType<T> to;
int distance;
TypeConverter<T, F> typeConverter;
@Override
public int hashCode() {
return from.hashCode() ^ to.hashCode();
}
@Override
public boolean equals(Object obj) {
ConverterEntry other = (ConverterEntry)obj;
return from.equals(other.from) && to.equals(other.to);
}
}
public static class ConverterEntries {
public ArrayList<ConverterEntry> list = new ArrayList<>();
public ConverterEntries() {
}
public ConverterEntries(ConverterEntries other) {
list.addAll(other.list);
}
public synchronized <F, T> void addConverter(Class<F> from, String fromMime, Class<T> to, String toMime, TypeConverter<T, F> typeConverter) {
addConverter(from, fromMime, to, toMime, 1, typeConverter);
}
public synchronized <F, T> void addConverter(Class<F> from, String fromMime, Class<T> to, String toMime, int distance, TypeConverter<T, F> typeConverter) {
if (TextUtils.isEmpty(fromMime))
fromMime = MIME_ALL;
if (TextUtils.isEmpty(toMime))
toMime = MIME_ALL;
list.add(new ConverterEntry<>(from, fromMime, to, toMime, distance, typeConverter));
}
public synchronized boolean removeConverter(TypeConverter typeConverter) {
for (ConverterEntry entry: list) {
if (entry.typeConverter == typeConverter)
return list.remove(entry);
}
return false;
}
}
public final static ConverterEntries Converters = new ConverterEntries();
static {
// ensure byte buffer operations are idempotent. do deep copies.
final TypeConverter<ByteBufferList, byte[]> ByteArrayToByteBufferList = (from, fromMime) ->
new SimpleFuture<>(new ByteBufferList(ByteBufferList.deepCopy(ByteBuffer.wrap(from))));
final TypeConverter<byte[], ByteBufferList> ByteBufferListToByteArray = (from, fromMime) ->
new SimpleFuture<>(from.getAllByteArray());
final TypeConverter<ByteBuffer, ByteBufferList> ByteBufferListToByteBuffer = (from, fromMime) ->
new SimpleFuture<>(from.getAll());
final TypeConverter<String, ByteBufferList> ByteBufferListToString = (from, fromMime) ->
new SimpleFuture<>(from.peekString());
final TypeConverter<ByteBuffer, byte[]> ByteArrayToByteBuffer = (from, fromMime) ->
new SimpleFuture<>(ByteBufferList.deepCopy(ByteBuffer.wrap(from)));
final TypeConverter<ByteBufferList, ByteBuffer> ByteBufferToByteBufferList = (from, fromMime) ->
new SimpleFuture<>(new ByteBufferList(ByteBufferList.deepCopy(from)));
final TypeConverter<byte[], String> StringToByteArray = (from, fromMime) -> new SimpleFuture<>(from.getBytes());
final TypeConverter<JSONObject, String> StringToJSONObject = (from, fromMime) -> new SimpleFuture<>(from).thenConvert(JSONObject::new);
final TypeConverter<String, JSONObject> JSONObjectToString = (from, fromMime) -> new SimpleFuture<>(from).thenConvert(JSONObject::toString);
final TypeConverter<String, byte[]> ByteArrayToString = (from, fromMime) -> new SimpleFuture<>(new String(from));
Converters.addConverter(ByteBuffer.class, null, ByteBufferList.class, null, ByteBufferToByteBufferList);
Converters.addConverter(String.class, null, byte[].class, "text/plain", StringToByteArray);
Converters.addConverter(byte[].class, null, ByteBufferList.class, null, ByteArrayToByteBufferList);
Converters.addConverter(ByteBufferList.class, null, byte[].class, null, ByteBufferListToByteArray);
Converters.addConverter(ByteBufferList.class, null, ByteBuffer.class, null, ByteBufferListToByteBuffer);
Converters.addConverter(ByteBufferList.class, "text/plain", String.class, null, ByteBufferListToString);
Converters.addConverter(byte[].class, null, ByteBuffer.class, null, ByteArrayToByteBuffer);
Converters.addConverter(String.class, "application/json", JSONObject.class, null, StringToJSONObject);
Converters.addConverter(JSONObject.class, null, String.class, "application/json", JSONObjectToString);
Converters.addConverter(byte[].class, "text/plain", String.class, null, ByteArrayToString);
}
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/DependentCancellable.java
================================================
package com.koushikdutta.async.future;
public interface DependentCancellable extends Cancellable {
boolean setParent(Cancellable parent);
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/DependentFuture.java
================================================
package com.koushikdutta.async.future;
public interface DependentFuture<T> extends Future<T>, DependentCancellable {
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/DoneCallback.java
================================================
package com.koushikdutta.async.future;
public interface DoneCallback<T> {
void done(Exception e, T result) throws Exception;
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/FailCallback.java
================================================
package com.koushikdutta.async.future;
public interface FailCallback {
/**
* Callback that is invoked when a future completes with an error.
* The error should be rethrown to pass it along.
* @param e
* @throws Exception
*/
void fail(Exception e) throws Exception;
}
================================================
FILE: AndroidAsync/src/com/koushikdutta/async/future/FailConvertCallback.java
================================================
package com.koushikdutta.async.future;
public interface FailConvertCallback<T> {
/**
* Callback that is invoked when a future completes with an error.
* The error
gitextract_o_k792rl/ ├── .github/ │ └── FUNDING.yml ├── .gitignore ├── AndroidAsync/ │ ├── .classpath │ ├── Android.mk │ ├── AndroidManifest.xml │ ├── build.gradle │ ├── lint.xml │ ├── maven.gradle │ ├── proguard-project.txt │ ├── project.properties │ ├── res/ │ │ └── .gitignore │ ├── src/ │ │ └── com/ │ │ └── koushikdutta/ │ │ └── async/ │ │ ├── AsyncDatagramSocket.java │ │ ├── AsyncNetworkSocket.java │ │ ├── AsyncSSLException.java │ │ ├── AsyncSSLServerSocket.java │ │ ├── AsyncSSLSocket.java │ │ ├── AsyncSSLSocketWrapper.java │ │ ├── AsyncSemaphore.java │ │ ├── AsyncServer.java │ │ ├── AsyncServerSocket.java │ │ ├── AsyncSocket.java │ │ ├── BufferedDataSink.java │ │ ├── ByteBufferList.java │ │ ├── ChannelWrapper.java │ │ ├── DataEmitter.java │ │ ├── DataEmitterBase.java │ │ ├── DataEmitterReader.java │ │ ├── DataSink.java │ │ ├── DataTrackingEmitter.java │ │ ├── DatagramChannelWrapper.java │ │ ├── FileDataEmitter.java │ │ ├── FilteredDataEmitter.java │ │ ├── FilteredDataSink.java │ │ ├── HostnameResolutionException.java │ │ ├── LineEmitter.java │ │ ├── PushParser.java │ │ ├── SelectorWrapper.java │ │ ├── ServerSocketChannelWrapper.java │ │ ├── SocketChannelWrapper.java │ │ ├── TapCallback.java │ │ ├── ThreadQueue.java │ │ ├── Util.java │ │ ├── ZipDataSink.java │ │ ├── callback/ │ │ │ ├── CompletedCallback.java │ │ │ ├── ConnectCallback.java │ │ │ ├── ContinuationCallback.java │ │ │ ├── DataCallback.java │ │ │ ├── ListenCallback.java │ │ │ ├── ResultCallback.java │ │ │ ├── SocketCreateCallback.java │ │ │ ├── ValueCallback.java │ │ │ ├── ValueFunction.java │ │ │ └── WritableCallback.java │ │ ├── dns/ │ │ │ ├── Dns.java │ │ │ └── DnsResponse.java │ │ ├── future/ │ │ │ ├── Cancellable.java │ │ │ ├── Continuation.java │ │ │ ├── Converter.java │ │ │ ├── DependentCancellable.java │ │ │ ├── DependentFuture.java │ │ │ ├── DoneCallback.java │ │ │ ├── FailCallback.java │ │ │ ├── FailConvertCallback.java │ │ │ ├── FailRecoverCallback.java │ │ │ ├── Future.java │ │ │ ├── FutureCallback.java │ │ │ ├── FutureRunnable.java │ │ │ ├── FutureThread.java │ │ │ ├── Futures.java │ │ │ ├── HandlerFuture.java │ │ │ ├── MultiFuture.java │ │ │ ├── MultiTransformFuture.java │ │ │ ├── SimpleCancellable.java │ │ │ ├── SimpleFuture.java │ │ │ ├── SuccessCallback.java │ │ │ ├── ThenCallback.java │ │ │ ├── ThenFutureCallback.java │ │ │ ├── TransformFuture.java │ │ │ └── TypeConverter.java │ │ ├── http/ │ │ │ ├── AsyncHttpClient.java │ │ │ ├── AsyncHttpClientMiddleware.java │ │ │ ├── AsyncHttpDelete.java │ │ │ ├── AsyncHttpGet.java │ │ │ ├── AsyncHttpHead.java │ │ │ ├── AsyncHttpPost.java │ │ │ ├── AsyncHttpPut.java │ │ │ ├── AsyncHttpRequest.java │ │ │ ├── AsyncHttpResponse.java │ │ │ ├── AsyncHttpResponseImpl.java │ │ │ ├── AsyncSSLEngineConfigurator.java │ │ │ ├── AsyncSSLSocketMiddleware.java │ │ │ ├── AsyncSocketMiddleware.java │ │ │ ├── BasicNameValuePair.java │ │ │ ├── BodyDecoderException.java │ │ │ ├── ConnectionClosedException.java │ │ │ ├── ConnectionFailedException.java │ │ │ ├── Headers.java │ │ │ ├── HttpDate.java │ │ │ ├── HttpTransportMiddleware.java │ │ │ ├── HttpUtil.java │ │ │ ├── HybiParser.java │ │ │ ├── Multimap.java │ │ │ ├── NameValuePair.java │ │ │ ├── Protocol.java │ │ │ ├── ProtocolVersion.java │ │ │ ├── RedirectLimitExceededException.java │ │ │ ├── RequestLine.java │ │ │ ├── SSLEngineSNIConfigurator.java │ │ │ ├── SimpleMiddleware.java │ │ │ ├── WebSocket.java │ │ │ ├── WebSocketHandshakeException.java │ │ │ ├── WebSocketImpl.java │ │ │ ├── body/ │ │ │ │ ├── AsyncHttpRequestBody.java │ │ │ │ ├── ByteBufferListRequestBody.java │ │ │ │ ├── DocumentBody.java │ │ │ │ ├── FileBody.java │ │ │ │ ├── FilePart.java │ │ │ │ ├── JSONArrayBody.java │ │ │ │ ├── JSONObjectBody.java │ │ │ │ ├── MultipartFormDataBody.java │ │ │ │ ├── Part.java │ │ │ │ ├── StreamBody.java │ │ │ │ ├── StreamPart.java │ │ │ │ ├── StringBody.java │ │ │ │ ├── StringPart.java │ │ │ │ └── UrlEncodedFormBody.java │ │ │ ├── cache/ │ │ │ │ ├── HeaderParser.java │ │ │ │ ├── Objects.java │ │ │ │ ├── RawHeaders.java │ │ │ │ ├── RequestHeaders.java │ │ │ │ ├── ResponseCacheMiddleware.java │ │ │ │ ├── ResponseHeaders.java │ │ │ │ ├── ResponseSource.java │ │ │ │ └── StrictLineReader.java │ │ │ ├── callback/ │ │ │ │ ├── HttpConnectCallback.java │ │ │ │ └── RequestCallback.java │ │ │ ├── filter/ │ │ │ │ ├── ChunkedDataException.java │ │ │ │ ├── ChunkedInputFilter.java │ │ │ │ ├── ChunkedOutputFilter.java │ │ │ │ ├── ContentLengthFilter.java │ │ │ │ ├── DataRemainingException.java │ │ │ │ ├── GZIPInputFilter.java │ │ │ │ ├── InflaterInputFilter.java │ │ │ │ └── PrematureDataEndException.java │ │ │ └── server/ │ │ │ ├── AsyncHttpRequestBodyProvider.java │ │ │ ├── AsyncHttpServer.java │ │ │ ├── AsyncHttpServerRequest.java │ │ │ ├── AsyncHttpServerRequestImpl.java │ │ │ ├── AsyncHttpServerResponse.java │ │ │ ├── AsyncHttpServerResponseImpl.java │ │ │ ├── AsyncHttpServerRouter.java │ │ │ ├── AsyncProxyServer.java │ │ │ ├── BoundaryEmitter.java │ │ │ ├── HttpServerRequestCallback.java │ │ │ ├── MalformedRangeException.java │ │ │ ├── MimeEncodingException.java │ │ │ ├── RouteMatcher.java │ │ │ ├── StreamSkipException.java │ │ │ └── UnknownRequestBody.java │ │ ├── parser/ │ │ │ ├── AsyncParser.java │ │ │ ├── ByteBufferListParser.java │ │ │ ├── DocumentParser.java │ │ │ ├── JSONArrayParser.java │ │ │ ├── JSONObjectParser.java │ │ │ └── StringParser.java │ │ ├── stream/ │ │ │ ├── ByteBufferListInputStream.java │ │ │ ├── FileDataSink.java │ │ │ ├── InputStreamDataEmitter.java │ │ │ ├── OutputStreamDataCallback.java │ │ │ └── OutputStreamDataSink.java │ │ ├── util/ │ │ │ ├── Allocator.java │ │ │ ├── ArrayDeque.java │ │ │ ├── Charsets.java │ │ │ ├── Deque.java │ │ │ ├── FileCache.java │ │ │ ├── FileUtility.java │ │ │ ├── HashList.java │ │ │ ├── IdleTimeout.java │ │ │ ├── LruCache.java │ │ │ ├── StreamUtility.java │ │ │ ├── TaggedList.java │ │ │ ├── ThrottleTimeout.java │ │ │ ├── TimeoutBase.java │ │ │ └── UntypedHashtable.java │ │ └── wrapper/ │ │ ├── AsyncSocketWrapper.java │ │ └── DataEmitterWrapper.java │ └── test/ │ ├── assets/ │ │ ├── 6691924d7d24237d3b3679310157d640 │ │ ├── hello.txt │ │ └── test.json │ ├── res/ │ │ ├── raw/ │ │ │ └── keystore.bks │ │ └── values/ │ │ └── strings.xml │ └── src/ │ └── com/ │ └── koushikdutta/ │ └── async/ │ └── test/ │ ├── BodyTests.java │ ├── ByteUtilTests.java │ ├── CacheTests.java │ ├── CallbackTests.java │ ├── ConscryptTests.java │ ├── ConvertTests.java │ ├── DnsTests.java │ ├── FileCacheTests.java │ ├── FileTests.java │ ├── FutureTests.java │ ├── HttpClientTests.java │ ├── HttpServerTests.java │ ├── Issue59.java │ ├── IssueWithWebSocketFuturesTests.java │ ├── LineEmitterTests.java │ ├── Md5.java │ ├── MultipartTests.java │ ├── ParserTests.java │ ├── ProxyTests.java │ ├── RedirectTests.java │ ├── SSLTests.java │ ├── SanityChecks.java │ ├── TimeoutTests.java │ ├── TriggerFuture.java │ └── WebSocketTests.java ├── AndroidAsync-Kotlin/ │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── koushikdutta/ │ │ └── async/ │ │ └── kotlin/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ └── java/ │ │ └── com/ │ │ └── koushikdutta/ │ │ └── async/ │ │ └── kotlin/ │ │ └── FutureExtensions.kt │ └── test/ │ └── java/ │ └── com/ │ └── koushikdutta/ │ └── async/ │ └── kotlin/ │ └── ExampleUnitTest.kt ├── AndroidAsyncSample/ │ ├── AndroidManifest.xml │ ├── build.gradle │ ├── proguard-project.txt │ ├── project.properties │ ├── res/ │ │ ├── layout/ │ │ │ └── activity_main.xml │ │ ├── menu/ │ │ │ └── activity_main.xml │ │ ├── values/ │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ ├── values-v11/ │ │ │ └── styles.xml │ │ └── values-v14/ │ │ └── styles.xml │ └── src/ │ └── com/ │ └── koushikdutta/ │ └── async/ │ └── sample/ │ ├── MainActivity.java │ └── middleware/ │ ├── BasicAuthMiddleware.java │ └── CacheOverrideMiddleware.java ├── LICENSE ├── README.md ├── build.gradle ├── gradlew ├── gradlew.bat └── settings.gradle
SYMBOL INDEX (2099 symbols across 203 files)
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncDatagramSocket.java
class AsyncDatagramSocket (line 7) | public class AsyncDatagramSocket extends AsyncNetworkSocket {
method disconnect (line 8) | public void disconnect() throws IOException {
method getRemoteAddress (line 13) | @Override
method connect (line 20) | public void connect(InetSocketAddress address) throws IOException {
method send (line 25) | public void send(final String host, final int port, final ByteBuffer b...
method send (line 46) | public void send(final InetSocketAddress address, final ByteBuffer buf...
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java
class AsyncNetworkSocket (line 20) | public class AsyncNetworkSocket implements AsyncSocket {
method AsyncNetworkSocket (line 21) | AsyncNetworkSocket() {
method end (line 24) | @Override
method isChunked (line 29) | public boolean isChunked() {
method attach (line 34) | void attach(SocketChannel channel, InetSocketAddress socketAddress) th...
method attach (line 40) | void attach(DatagramChannel channel) throws IOException {
method getChannel (line 47) | ChannelWrapper getChannel() {
method onDataWritable (line 51) | public void onDataWritable() {
method setup (line 64) | void setup(AsyncServer server, SelectionKey key) {
method write (line 69) | @Override
method handleRemaining (line 99) | private void handleRemaining(int remaining) throws IOException {
method onReadable (line 117) | int onReadable() {
method reportClose (line 175) | protected void reportClose(Exception e) {
method close (line 185) | @Override
method closeInternal (line 191) | private void closeInternal() {
method setWriteableCallback (line 201) | @Override
method setDataCallback (line 207) | @Override
method getDataCallback (line 212) | @Override
method setClosedCallback (line 218) | @Override
method getClosedCallback (line 223) | @Override
method getWriteableCallback (line 228) | @Override
method reportEnd (line 233) | void reportEnd(Exception e) {
method reportEndPending (line 245) | void reportEndPending(Exception e) {
method setEndCallback (line 254) | @Override
method getEndCallback (line 259) | @Override
method isOpen (line 264) | @Override
method pause (line 270) | @Override
method spitPending (line 293) | private void spitPending() {
method resume (line 299) | @Override
method isPaused (line 324) | @Override
method getServer (line 329) | @Override
method getRemoteAddress (line 335) | public InetSocketAddress getRemoteAddress() {
method getLocalAddress (line 339) | public InetAddress getLocalAddress() {
method getLocalPort (line 343) | public int getLocalPort() {
method getSocket (line 347) | public Object getSocket() {
method charset (line 351) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLException.java
class AsyncSSLException (line 3) | public class AsyncSSLException extends Exception {
method AsyncSSLException (line 4) | public AsyncSSLException(Throwable cause) {
method setIgnore (line 8) | public void setIgnore(boolean ignore) {
method getIgnore (line 12) | public boolean getIgnore() {
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLServerSocket.java
type AsyncSSLServerSocket (line 6) | public interface AsyncSSLServerSocket extends AsyncServerSocket {
method getPrivateKey (line 7) | PrivateKey getPrivateKey();
method getCertificate (line 8) | Certificate getCertificate();
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocket.java
type AsyncSSLSocket (line 7) | public interface AsyncSSLSocket extends AsyncSocket {
method getPeerCertificates (line 8) | public X509Certificate[] getPeerCertificates();
method getSSLEngine (line 9) | public SSLEngine getSSLEngine();
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocketWrapper.java
class AsyncSSLSocketWrapper (line 72) | public class AsyncSSLSocketWrapper implements AsyncSocketWrapper, AsyncS...
type HandshakeCallback (line 75) | public interface HandshakeCallback {
method onHandshakeCompleted (line 76) | public void onHandshakeCompleted(Exception e, AsyncSSLSocket socket);
method getAcceptedIssuers (line 116) | public java.security.cert.X509Certificate[] getAcceptedIssuers() {
method checkClientTrusted (line 120) | public void checkClientTrusted(java.security.cert.X509Certificate[] ce...
method checkServerTrusted (line 123) | public void checkServerTrusted(java.security.cert.X509Certificate[] ce...
method getAcceptedIssuers (line 142) | public java.security.cert.X509Certificate[] getAcceptedIssuers() {
method checkClientTrusted (line 146) | public void checkClientTrusted(java.security.cert.X509Certificate[] ce...
method checkServerTrusted (line 149) | public void checkServerTrusted(java.security.cert.X509Certificate[] ce...
method getDefaultSSLContext (line 160) | public static SSLContext getDefaultSSLContext() {
method handshake (line 164) | public static void handshake(AsyncSocket socket,
method connectSocket (line 188) | public static Cancellable connectSocket(AsyncServer server, String hos...
method connectSocket (line 191) | public static Cancellable connectSocket(AsyncServer server, String hos...
method AsyncSSLSocketWrapper (line 226) | private AsyncSSLSocketWrapper(AsyncSocket socket,
method onDataAvailable (line 270) | @Override
method onDataAvailable (line 334) | public void onDataAvailable() {
method getSSLEngine (line 342) | @Override
method addToPending (line 347) | void addToPending(ByteBufferList out, ByteBuffer mReadTmp) {
method end (line 358) | @Override
method getHost (line 363) | public String getHost() {
method getPort (line 367) | public int getPort() {
method handleHandshakeStatus (line 371) | private void handleHandshakeStatus(HandshakeStatus status) {
method calculateAlloc (line 442) | int calculateAlloc(int remaining) {
method write (line 451) | @Override
method setWriteableCallback (line 496) | @Override
method getWriteableCallback (line 501) | @Override
method report (line 506) | private void report(Exception e) {
method setDataCallback (line 524) | @Override
method getDataCallback (line 529) | @Override
method isChunked (line 534) | @Override
method isOpen (line 539) | @Override
method close (line 544) | @Override
method setClosedCallback (line 549) | @Override
method getClosedCallback (line 554) | @Override
method setEndCallback (line 560) | @Override
method getEndCallback (line 565) | @Override
method pause (line 570) | @Override
method resume (line 575) | @Override
method isPaused (line 581) | @Override
method getServer (line 586) | @Override
method getSocket (line 591) | @Override
method getDataEmitter (line 596) | @Override
method getPeerCertificates (line 601) | @Override
method charset (line 606) | @Override
method selfSign (line 611) | private static Certificate selfSign(KeyPair keyPair, String subjectDN)...
method selfSignCertificate (line 646) | public static Pair<KeyPair, Certificate> selfSignCertificate(final Con...
method listenSecure (line 680) | public static AsyncSSLServerSocket listenSecure(final Context context,...
method listenSecure (line 697) | public static AsyncSSLServerSocket listenSecure(AsyncServer server, St...
class ObjectHolder (line 701) | private static class ObjectHolder<T> {
method listenSecure (line 705) | public static AsyncSSLServerSocket listenSecure(final AsyncServer serv...
method listenSecure (line 723) | public static AsyncSSLServerSocket listenSecure(final AsyncServer serv...
method listenSecure (line 771) | public static AsyncServerSocket listenSecure(AsyncServer server, final...
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSemaphore.java
class AsyncSemaphore (line 6) | public class AsyncSemaphore {
method acquire (line 10) | public void acquire() throws InterruptedException {
method tryAcquire (line 40) | public boolean tryAcquire(long timeout, TimeUnit timeunit) throws Inte...
method release (line 76) | public void release() {
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncServer.java
class AsyncServer (line 46) | public class AsyncServer {
class RunnableWrapper (line 49) | private static class RunnableWrapper implements Runnable {
method run (line 54) | @Override
method post (line 75) | public static void post(Handler handler, Runnable runnable) {
method getDefault (line 102) | public static AsyncServer getDefault() {
method isRunning (line 108) | public boolean isRunning() {
method AsyncServer (line 113) | public AsyncServer() {
method AsyncServer (line 117) | public AsyncServer(String name) {
method wakeup (line 124) | private static void wakeup(final SelectorWrapper selector) {
method kill (line 135) | public void kill() {
method postDelayed (line 143) | public Cancellable postDelayed(Runnable runnable, long delay) {
method postImmediate (line 177) | public Cancellable postImmediate(Runnable runnable) {
method post (line 185) | public Cancellable post(Runnable runnable) {
method post (line 189) | public Cancellable post(final CompletedCallback callback, final Except...
method run (line 193) | public void run(final Runnable runnable) {
class Scheduled (line 218) | private static class Scheduled implements Cancellable, Runnable {
method Scheduled (line 221) | public Scheduled(AsyncServer server, Runnable runnable, long time) {
method run (line 230) | @Override
method isDone (line 235) | @Override
method isCancelled (line 243) | @Override
method cancel (line 248) | @Override
class Scheduler (line 257) | static class Scheduler implements Comparator<Scheduled> {
method Scheduler (line 259) | private Scheduler() {
method compare (line 261) | @Override
method stop (line 273) | public void stop() {
method stop (line 277) | public void stop(boolean wait) {
method onDataReceived (line 320) | protected void onDataReceived(int transmitted) {
method onDataSent (line 323) | protected void onDataSent(int transmitted) {
class ObjectHolder (line 326) | private static class ObjectHolder<T> {
method listen (line 329) | public AsyncServerSocket listen(final InetAddress host, final int port...
class ConnectFuture (line 377) | private class ConnectFuture extends SimpleFuture<AsyncNetworkSocket> {
method cancelCleanup (line 378) | @Override
method connectResolvedInetSocketAddress (line 393) | public Cancellable connectResolvedInetSocketAddress(final InetSocketAd...
method connectResolvedInetSocketAddress (line 397) | public ConnectFuture connectResolvedInetSocketAddress(final InetSocket...
method connectSocket (line 430) | public Cancellable connectSocket(final InetSocketAddress remote, final...
method connectSocket (line 454) | public Cancellable connectSocket(final String host, final int port, fi...
method newSynchronousWorkers (line 458) | private static ExecutorService newSynchronousWorkers(String prefix) {
method compare (line 466) | @Override
method getAllByName (line 479) | public Future<InetAddress[]> getAllByName(final String host) {
method getByName (line 508) | public Future<InetAddress> getByName(String host) {
method handleSocket (line 512) | private void handleSocket(final AsyncNetworkSocket handler) throws Clo...
method connectDatagram (line 519) | public AsyncDatagramSocket connectDatagram(final String host, final in...
method openDatagram (line 543) | public AsyncDatagramSocket openDatagram() {
method createDatagram (line 547) | public Cancellable createDatagram(String address, int port, boolean re...
method createDatagram (line 551) | public Cancellable createDatagram(InetAddress address, int port, boole...
method createDatagram (line 555) | private Cancellable createDatagram(ValueFunction<InetAddress> inetAddr...
method openDatagram (line 588) | public AsyncDatagramSocket openDatagram(final InetAddress host, final ...
method connectDatagram (line 630) | public AsyncDatagramSocket connectDatagram(final SocketAddress remote)...
method getCurrentThreadServer (line 658) | public static AsyncServer getCurrentThreadServer() {
method run (line 663) | private void run() {
method run (line 715) | private static void run(final AsyncServer server, final SelectorWrappe...
method shutdownKeys (line 750) | private static void shutdownKeys(SelectorWrapper selector) {
method shutdownEverything (line 765) | private static void shutdownEverything(SelectorWrapper selector) {
method lockAndRunQueue (line 772) | private static long lockAndRunQueue(final AsyncServer server, final Pr...
class AsyncSelectorException (line 804) | private static class AsyncSelectorException extends IOException {
method AsyncSelectorException (line 805) | public AsyncSelectorException(Exception e) {
method runLoop (line 810) | private static void runLoop(final AsyncServer server, final SelectorWr...
method dump (line 918) | public void dump() {
method getAffinity (line 935) | public Thread getAffinity() {
method isAffinityThread (line 939) | public boolean isAffinityThread() {
method isAffinityThreadOrStopped (line 943) | public boolean isAffinityThreadOrStopped() {
class NamedThreadFactory (line 948) | private static class NamedThreadFactory implements ThreadFactory {
method NamedThreadFactory (line 953) | NamedThreadFactory(String namePrefix) {
method newThread (line 960) | public Thread newThread(Runnable r) {
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncServerSocket.java
type AsyncServerSocket (line 3) | public interface AsyncServerSocket {
method stop (line 4) | public void stop();
method getLocalPort (line 5) | public int getLocalPort();
FILE: AndroidAsync/src/com/koushikdutta/async/AsyncSocket.java
type AsyncSocket (line 4) | public interface AsyncSocket extends DataEmitter, DataSink {
method getServer (line 5) | public AsyncServer getServer();
FILE: AndroidAsync/src/com/koushikdutta/async/BufferedDataSink.java
class BufferedDataSink (line 6) | public class BufferedDataSink implements DataSink {
method BufferedDataSink (line 8) | public BufferedDataSink(DataSink datasink) {
method isBuffering (line 12) | public boolean isBuffering() {
method isWritable (line 16) | public boolean isWritable() {
method getDataSink (line 22) | public DataSink getDataSink() {
method forceBuffering (line 27) | public void forceBuffering(boolean forceBuffering) {
method setDataSink (line 33) | public void setDataSink(DataSink datasink) {
method writePending (line 38) | private void writePending() {
method onDataAccepted (line 60) | protected void onDataAccepted(ByteBufferList bb) {
method write (line 63) | @Override
method setWriteableCallback (line 87) | @Override
method getWriteableCallback (line 92) | @Override
method remaining (line 97) | public int remaining() {
method getMaxBuffer (line 102) | public int getMaxBuffer() {
method setMaxBuffer (line 106) | public void setMaxBuffer(int maxBuffer) {
method isOpen (line 110) | @Override
method end (line 116) | @Override
method setClosedCallback (line 132) | @Override
method getClosedCallback (line 137) | @Override
method getServer (line 142) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java
class ByteBufferList (line 18) | @TargetApi(Build.VERSION_CODES.GINGERBREAD)
method order (line 23) | public ByteOrder order() {
method order (line 27) | public ByteBufferList order(ByteOrder order) {
method ByteBufferList (line 32) | public ByteBufferList() {
method ByteBufferList (line 35) | public ByteBufferList(ByteBuffer... b) {
method ByteBufferList (line 39) | public ByteBufferList(byte[] buf) {
method addAll (line 45) | public ByteBufferList addAll(ByteBuffer... bb) {
method addAll (line 51) | public ByteBufferList addAll(ByteBufferList... bb) {
method getBytes (line 57) | public byte[] getBytes(int length) {
method getAllByteArray (line 63) | public byte[] getAllByteArray() {
method getAllArray (line 69) | public ByteBuffer[] getAllArray() {
method isEmpty (line 77) | public boolean isEmpty() {
method remaining (line 82) | public int remaining() {
method hasRemaining (line 86) | public boolean hasRemaining() {
method peekShort (line 90) | public short peekShort() {
method peek (line 94) | public byte peek() {
method peekInt (line 98) | public int peekInt() {
method peekLong (line 102) | public long peekLong() {
method peekBytes (line 106) | public byte[] peekBytes(int size) {
method skip (line 112) | public ByteBufferList skip(int length) {
method getInt (line 117) | public int getInt() {
method getByteChar (line 123) | public char getByteChar() {
method getShort (line 129) | public short getShort() {
method get (line 135) | public byte get() {
method getLong (line 141) | public long getLong() {
method get (line 147) | public void get(byte[] bytes) {
method get (line 151) | public void get(byte[] bytes, int offset, int length) {
method get (line 176) | public void get(ByteBufferList into, int length) {
method get (line 211) | public void get(ByteBufferList into) {
method get (line 215) | public ByteBufferList get(int length) {
method getAll (line 221) | public ByteBuffer getAll() {
method read (line 228) | private ByteBuffer read(int count) {
method trim (line 269) | public void trim() {
method add (line 274) | public ByteBufferList add(ByteBufferList b) {
method add (line 279) | public ByteBufferList add(ByteBuffer b) {
method addFirst (line 307) | public void addFirst(ByteBuffer b) {
method addRemaining (line 329) | private void addRemaining(int remaining) {
method recycle (line 334) | public void recycle() {
method remove (line 341) | public ByteBuffer remove() {
method size (line 347) | public int size() {
method spewString (line 351) | public void spewString() {
method peekString (line 355) | public String peekString() {
method peekString (line 360) | public String peekString(Charset charset) {
method readString (line 384) | public String readString() {
method readString (line 388) | public String readString(Charset charset) {
class Reclaimer (line 394) | static class Reclaimer implements Comparator<ByteBuffer> {
method compare (line 395) | @Override
method getReclaimed (line 408) | private static PriorityQueue<ByteBuffer> getReclaimed() {
method setMaxPoolSize (line 422) | public static void setMaxPoolSize(int size) {
method setMaxItemSize (line 426) | public static void setMaxItemSize(int size) {
method reclaimedContains (line 430) | private static boolean reclaimedContains(ByteBuffer b) {
method reclaim (line 438) | public static void reclaim(ByteBuffer b) {
method obtain (line 476) | public static ByteBuffer obtain(int size) {
method obtainArray (line 501) | public static void obtainArray(ByteBuffer[] arr, int size) {
method deepCopy (line 528) | public static ByteBuffer deepCopy(ByteBuffer copyOf) {
method writeOutputStream (line 536) | public static void writeOutputStream(OutputStream out, ByteBuffer b) t...
FILE: AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java
class ChannelWrapper (line 13) | abstract class ChannelWrapper implements ReadableByteChannel, Scattering...
method ChannelWrapper (line 15) | ChannelWrapper(AbstractSelectableChannel channel) throws IOException {
method shutdownInput (line 20) | public abstract void shutdownInput();
method shutdownOutput (line 21) | public abstract void shutdownOutput();
method isConnected (line 23) | public abstract boolean isConnected();
method write (line 25) | public abstract int write(ByteBuffer src) throws IOException;
method write (line 26) | public abstract int write(ByteBuffer[] src) throws IOException;
method register (line 29) | public abstract SelectionKey register(Selector sel) throws ClosedChann...
method register (line 31) | public SelectionKey register(Selector sel, int ops) throws ClosedChann...
method isChunked (line 35) | public boolean isChunked() {
method isOpen (line 39) | @Override
method close (line 44) | @Override
method getLocalPort (line 49) | public abstract int getLocalPort();
method getLocalAddress (line 50) | public abstract InetAddress getLocalAddress();
method getSocket (line 51) | public abstract Object getSocket();
FILE: AndroidAsync/src/com/koushikdutta/async/DataEmitter.java
type DataEmitter (line 6) | public interface DataEmitter {
method setDataCallback (line 7) | void setDataCallback(DataCallback callback);
method getDataCallback (line 8) | DataCallback getDataCallback();
method isChunked (line 9) | boolean isChunked();
method pause (line 10) | void pause();
method resume (line 11) | void resume();
method close (line 12) | void close();
method isPaused (line 13) | boolean isPaused();
method setEndCallback (line 14) | void setEndCallback(CompletedCallback callback);
method getEndCallback (line 15) | CompletedCallback getEndCallback();
method getServer (line 16) | AsyncServer getServer();
method charset (line 17) | String charset();
FILE: AndroidAsync/src/com/koushikdutta/async/DataEmitterBase.java
class DataEmitterBase (line 9) | public abstract class DataEmitterBase implements DataEmitter {
method report (line 11) | protected void report(Exception e) {
method setEndCallback (line 19) | @Override
method getEndCallback (line 25) | @Override
method setDataCallback (line 32) | @Override
method getDataCallback (line 37) | @Override
method charset (line 42) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java
class DataEmitterReader (line 5) | public class DataEmitterReader implements com.koushikdutta.async.callbac...
method read (line 10) | public void read(int count, DataCallback callback) {
method handlePendingData (line 16) | private boolean handlePendingData(DataEmitter emitter) {
method DataEmitterReader (line 27) | public DataEmitterReader() {
method onDataAvailable (line 29) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/DataSink.java
type DataSink (line 6) | public interface DataSink {
method write (line 7) | public void write(ByteBufferList bb);
method setWriteableCallback (line 8) | public void setWriteableCallback(WritableCallback handler);
method getWriteableCallback (line 9) | public WritableCallback getWriteableCallback();
method isOpen (line 11) | public boolean isOpen();
method end (line 12) | public void end();
method setClosedCallback (line 13) | public void setClosedCallback(CompletedCallback handler);
method getClosedCallback (line 14) | public CompletedCallback getClosedCallback();
method getServer (line 15) | public AsyncServer getServer();
FILE: AndroidAsync/src/com/koushikdutta/async/DataTrackingEmitter.java
type DataTrackingEmitter (line 6) | public interface DataTrackingEmitter extends DataEmitter {
type DataTracker (line 7) | interface DataTracker {
method onData (line 8) | void onData(int totalBytesRead);
method setDataTracker (line 10) | void setDataTracker(DataTracker tracker);
method getDataTracker (line 11) | DataTracker getDataTracker();
method getBytesRead (line 12) | int getBytesRead();
method setDataEmitter (line 13) | void setDataEmitter(DataEmitter emitter);
FILE: AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java
class DatagramChannelWrapper (line 12) | class DatagramChannelWrapper extends ChannelWrapper {
method getLocalAddress (line 15) | @Override
method getLocalPort (line 20) | @Override
method getRemoteAddress (line 26) | public InetSocketAddress getRemoteAddress() {
method disconnect (line 30) | public void disconnect() throws IOException {
method DatagramChannelWrapper (line 34) | DatagramChannelWrapper(DatagramChannel channel) throws IOException {
method read (line 38) | @Override
method isConnected (line 50) | @Override
method write (line 54) | @Override
method write (line 58) | @Override
method register (line 62) | @Override
method isChunked (line 66) | @Override
method register (line 70) | @Override
method shutdownOutput (line 75) | @Override
method shutdownInput (line 79) | @Override
method read (line 83) | @Override
method read (line 88) | @Override
method getSocket (line 93) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/FileDataEmitter.java
class FileDataEmitter (line 14) | public class FileDataEmitter extends DataEmitterBase {
method FileDataEmitter (line 17) | public FileDataEmitter(AsyncServer server, File file) {
method setDataCallback (line 26) | @Override
method getDataCallback (line 31) | @Override
method isChunked (line 36) | @Override
method pause (line 42) | @Override
method resume (line 47) | @Override
method report (line 53) | @Override
method run (line 62) | @Override
method doResume (line 91) | private void doResume() {
method isPaused (line 95) | @Override
method getServer (line 100) | @Override
method close (line 105) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/FilteredDataEmitter.java
class FilteredDataEmitter (line 7) | public class FilteredDataEmitter extends DataEmitterBase implements Data...
method getDataEmitter (line 9) | @Override
method setDataEmitter (line 14) | @Override
method getBytesRead (line 29) | @Override
method getDataTracker (line 34) | @Override
method setDataTracker (line 39) | @Override
method onDataAvailable (line 46) | @Override
method isChunked (line 65) | @Override
method pause (line 70) | @Override
method resume (line 75) | @Override
method isPaused (line 80) | @Override
method getServer (line 85) | @Override
method close (line 91) | @Override
method charset (line 98) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/FilteredDataSink.java
class FilteredDataSink (line 3) | public class FilteredDataSink extends BufferedDataSink {
method FilteredDataSink (line 4) | public FilteredDataSink(DataSink sink) {
method filter (line 9) | public ByteBufferList filter(ByteBufferList bb) {
method onDataAccepted (line 13) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/HostnameResolutionException.java
class HostnameResolutionException (line 3) | public class HostnameResolutionException extends Exception {
method HostnameResolutionException (line 4) | public HostnameResolutionException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/LineEmitter.java
class LineEmitter (line 8) | public class LineEmitter implements DataCallback {
type StringCallback (line 9) | public interface StringCallback {
method onStringAvailable (line 10) | void onStringAvailable(String s);
method LineEmitter (line 13) | public LineEmitter() {
method LineEmitter (line 17) | public LineEmitter(Charset charset) {
method setLineCallback (line 26) | public void setLineCallback(StringCallback callback) {
method getLineCallback (line 30) | public StringCallback getLineCallback() {
method onDataAvailable (line 34) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/PushParser.java
class PushParser (line 13) | public class PushParser implements DataCallback {
type ParseCallback (line 15) | public interface ParseCallback<T> {
method parsed (line 16) | public void parsed(T data);
class Waiter (line 19) | static abstract class Waiter {
method Waiter (line 21) | public Waiter(int length) {
method onDataAvailable (line 29) | public abstract Waiter onDataAvailable(DataEmitter emitter, ByteBuff...
class IntWaiter (line 32) | static class IntWaiter extends Waiter {
method IntWaiter (line 34) | public IntWaiter(ParseCallback<Integer> callback) {
method onDataAvailable (line 39) | @Override
class ByteArrayWaiter (line 46) | static class ByteArrayWaiter extends Waiter {
method ByteArrayWaiter (line 48) | public ByteArrayWaiter(int length, ParseCallback<byte[]> callback) {
method onDataAvailable (line 55) | @Override
class LenByteArrayWaiter (line 64) | static class LenByteArrayWaiter extends Waiter {
method LenByteArrayWaiter (line 67) | public LenByteArrayWaiter(ParseCallback<byte[]> callback) {
method onDataAvailable (line 72) | @Override
class ByteBufferListWaiter (line 84) | static class ByteBufferListWaiter extends Waiter {
method ByteBufferListWaiter (line 86) | public ByteBufferListWaiter(int length, ParseCallback<ByteBufferList...
method onDataAvailable (line 92) | @Override
class LenByteBufferListWaiter (line 99) | static class LenByteBufferListWaiter extends Waiter {
method LenByteBufferListWaiter (line 102) | public LenByteBufferListWaiter(ParseCallback<ByteBufferList> callbac...
method onDataAvailable (line 107) | @Override
class UntilWaiter (line 114) | static class UntilWaiter extends Waiter {
method UntilWaiter (line 118) | public UntilWaiter(byte value, DataCallback callback) {
method onDataAvailable (line 124) | @Override
class TapWaiter (line 157) | private class TapWaiter extends Waiter {
method TapWaiter (line 160) | public TapWaiter(TapCallback callback) {
method onDataAvailable (line 165) | @Override
method onDataAvailable (line 180) | @Override
method onDataAvailable (line 188) | @Override
method onDataAvailable (line 196) | @Override
method onDataAvailable (line 204) | @Override
method onDataAvailable (line 212) | @Override
method parsed (line 220) | @Override
method parsed (line 227) | @Override
method parsed (line 234) | @Override
method setOrder (line 245) | public PushParser setOrder(ByteOrder order) {
method PushParser (line 250) | public PushParser(DataEmitter s) {
method readInt (line 255) | public PushParser readInt(ParseCallback<Integer> callback) {
method readByteArray (line 260) | public PushParser readByteArray(int length, ParseCallback<byte[]> call...
method readByteBufferList (line 265) | public PushParser readByteBufferList(int length, ParseCallback<ByteBuf...
method until (line 270) | public PushParser until(byte b, DataCallback callback) {
method readByte (line 275) | public PushParser readByte() {
method readShort (line 280) | public PushParser readShort() {
method readInt (line 285) | public PushParser readInt() {
method readLong (line 290) | public PushParser readLong() {
method readByteArray (line 295) | public PushParser readByteArray(int length) {
method readLenByteArray (line 299) | public PushParser readLenByteArray() {
method readByteBufferList (line 304) | public PushParser readByteBufferList(int length) {
method readLenByteBufferList (line 308) | public PushParser readLenByteBufferList() {
method readLenByteBufferList (line 312) | public PushParser readLenByteBufferList(ParseCallback<ByteBufferList> ...
method readString (line 317) | public PushParser readString() {
method noop (line 322) | public PushParser noop() {
method onDataAvailable (line 328) | @Override
method tap (line 340) | public void tap(TapCallback callback) {
method getTap (line 345) | static Method getTap(TapCallback callback) {
FILE: AndroidAsync/src/com/koushikdutta/async/SelectorWrapper.java
class SelectorWrapper (line 15) | class SelectorWrapper implements Closeable {
method getSelector (line 19) | public Selector getSelector() {
method SelectorWrapper (line 23) | public SelectorWrapper(Selector selector) {
method selectNow (line 27) | public int selectNow() throws IOException {
method select (line 31) | public void select() throws IOException {
method select (line 35) | public void select(long timeout) throws IOException {
method keys (line 45) | public Set<SelectionKey> keys() {
method selectedKeys (line 49) | public Set<SelectionKey> selectedKeys() {
method close (line 53) | @Override
method isOpen (line 58) | public boolean isOpen() {
method wakeupOnce (line 62) | public void wakeupOnce() {
method waitForSelect (line 84) | public boolean waitForSelect() {
FILE: AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java
class ServerSocketChannelWrapper (line 11) | class ServerSocketChannelWrapper extends ChannelWrapper {
method shutdownOutput (line 14) | @Override
method shutdownInput (line 18) | @Override
method getLocalAddress (line 22) | @Override
method getLocalPort (line 27) | @Override
method ServerSocketChannelWrapper (line 32) | ServerSocketChannelWrapper(ServerSocketChannel channel) throws IOExcep...
method read (line 37) | @Override
method isConnected (line 43) | @Override
method write (line 48) | @Override
method register (line 54) | @Override
method write (line 59) | @Override
method read (line 65) | @Override
method read (line 71) | @Override
method getSocket (line 77) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java
class SocketChannelWrapper (line 11) | class SocketChannelWrapper extends ChannelWrapper {
method getLocalAddress (line 14) | @Override
method getLocalPort (line 19) | @Override
method SocketChannelWrapper (line 24) | SocketChannelWrapper(SocketChannel channel) throws IOException {
method read (line 28) | @Override
method isConnected (line 32) | @Override
method write (line 36) | @Override
method write (line 40) | @Override
method register (line 44) | @Override
method shutdownOutput (line 49) | @Override
method shutdownInput (line 58) | @Override
method read (line 67) | @Override
method read (line 72) | @Override
method getSocket (line 77) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/TapCallback.java
type TapCallback (line 4) | public interface TapCallback {
FILE: AndroidAsync/src/com/koushikdutta/async/ThreadQueue.java
class ThreadQueue (line 7) | class ThreadQueue extends LinkedList<Runnable> {
method getOrCreateThreadQueue (line 10) | static ThreadQueue getOrCreateThreadQueue(Thread thread) {
method release (line 23) | static void release(AsyncSemaphore semaphore) {
method add (line 35) | @Override
method remove (line 42) | @Override
method remove (line 49) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/Util.java
class Util (line 17) | public class Util {
method emitAllData (line 19) | public static void emitAllData(DataEmitter emitter, ByteBufferList lis...
method pump (line 56) | public static void pump(final InputStream is, final DataSink ds, final...
method pump (line 60) | public static void pump(final InputStream is, final long max, final Da...
method pump (line 121) | public static void pump(final DataEmitter emitter, final DataSink sink...
method stream (line 164) | public static void stream(AsyncSocket s1, AsyncSocket s2, CompletedCal...
method pump (line 169) | public static void pump(final File file, final DataSink ds, final Comp...
method writeAll (line 194) | public static void writeAll(final DataSink sink, final ByteBufferList ...
method writeAll (line 208) | public static void writeAll(DataSink sink, byte[] bytes, CompletedCall...
method getWrappedSocket (line 217) | public static <T extends AsyncSocket> T getWrappedSocket(AsyncSocket s...
method getWrappedDataEmitter (line 228) | public static DataEmitter getWrappedDataEmitter(DataEmitter emitter, C...
method end (line 239) | public static void end(DataEmitter emitter, Exception e) {
method end (line 245) | public static void end(CompletedCallback end, Exception e) {
method writable (line 250) | public static void writable(DataSink emitter) {
method writable (line 256) | public static void writable(WritableCallback writable) {
FILE: AndroidAsync/src/com/koushikdutta/async/ZipDataSink.java
class ZipDataSink (line 11) | public class ZipDataSink extends FilteredDataSink {
method ZipDataSink (line 12) | public ZipDataSink(DataSink sink) {
method putNextEntry (line 19) | public void putNextEntry(ZipEntry ze) throws IOException {
method closeEntry (line 23) | public void closeEntry() throws IOException {
method report (line 27) | protected void report(Exception e) {
method end (line 33) | @Override
method filter (line 47) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/callback/CompletedCallback.java
type CompletedCallback (line 3) | public interface CompletedCallback {
class NullCompletedCallback (line 4) | public class NullCompletedCallback implements CompletedCallback {
method onCompleted (line 5) | @Override
method onCompleted (line 11) | public void onCompleted(Exception ex);
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ConnectCallback.java
type ConnectCallback (line 5) | public interface ConnectCallback {
method onConnectCompleted (line 6) | public void onConnectCompleted(Exception ex, AsyncSocket socket);
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ContinuationCallback.java
type ContinuationCallback (line 5) | public interface ContinuationCallback {
method onContinue (line 6) | public void onContinue(Continuation continuation, CompletedCallback ne...
FILE: AndroidAsync/src/com/koushikdutta/async/callback/DataCallback.java
type DataCallback (line 7) | public interface DataCallback {
class NullDataCallback (line 8) | public class NullDataCallback implements DataCallback {
method onDataAvailable (line 9) | @Override
method onDataAvailable (line 15) | public void onDataAvailable(DataEmitter emitter, ByteBufferList bb);
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ListenCallback.java
type ListenCallback (line 7) | public interface ListenCallback extends CompletedCallback {
method onAccepted (line 8) | public void onAccepted(AsyncSocket socket);
method onListening (line 9) | public void onListening(AsyncServerSocket socket);
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ResultCallback.java
type ResultCallback (line 3) | public interface ResultCallback<S, T> {
method onCompleted (line 4) | public void onCompleted(Exception e, S source, T result);
FILE: AndroidAsync/src/com/koushikdutta/async/callback/SocketCreateCallback.java
type SocketCreateCallback (line 5) | public interface SocketCreateCallback {
method onSocketCreated (line 6) | void onSocketCreated(int localPort);
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ValueCallback.java
type ValueCallback (line 6) | public interface ValueCallback<T> {
method onResult (line 7) | void onResult(T value);
FILE: AndroidAsync/src/com/koushikdutta/async/callback/ValueFunction.java
type ValueFunction (line 3) | public interface ValueFunction<T> {
method getValue (line 4) | T getValue() throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/callback/WritableCallback.java
type WritableCallback (line 3) | public interface WritableCallback {
method onWriteable (line 4) | public void onWriteable();
FILE: AndroidAsync/src/com/koushikdutta/async/dns/Dns.java
class Dns (line 25) | public class Dns {
method lookup (line 26) | public static Future<DnsResponse> lookup(String host) {
method setFlag (line 30) | private static int setFlag(int flags, int value, int offset) {
method setQuery (line 34) | private static int setQuery(int flags) {
method setRecursion (line 38) | private static int setRecursion(int flags) {
method addName (line 42) | private static void addName(ByteBuffer bb, String name) {
method lookup (line 51) | public static Future<DnsResponse> lookup(AsyncServer server, String ho...
method multicastLookup (line 55) | public static Cancellable multicastLookup(AsyncServer server, String h...
method multicastLookup (line 59) | public static Cancellable multicastLookup(String host, FutureCallback<...
method lookup (line 63) | public static Future<DnsResponse> lookup(AsyncServer server, String ho...
FILE: AndroidAsync/src/com/koushikdutta/async/dns/DnsResponse.java
class DnsResponse (line 15) | public class DnsResponse {
method parseName (line 21) | private static String parseName(ByteBufferList bb, ByteBuffer backRefe...
method parse (line 49) | public static DnsResponse parse(ByteBufferList bb) {
method parseTxt (line 160) | void parseTxt(ByteBufferList bb) {
method toString (line 171) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/future/Cancellable.java
type Cancellable (line 3) | public interface Cancellable {
method isDone (line 8) | boolean isDone();
method isCancelled (line 14) | boolean isCancelled();
method cancel (line 20) | boolean cancel();
FILE: AndroidAsync/src/com/koushikdutta/async/future/Continuation.java
class Continuation (line 8) | public class Continuation extends SimpleCancellable implements Continuat...
method getCallback (line 12) | public CompletedCallback getCallback() {
method setCallback (line 15) | public void setCallback(CompletedCallback callback) {
method getCancelCallback (line 19) | public Runnable getCancelCallback() {
method setCancelCallback (line 22) | public void setCancelCallback(Runnable cancelCallback) {
method setCancelCallback (line 25) | public void setCancelCallback(final Cancellable cancel) {
method Continuation (line 38) | public Continuation() {
method Continuation (line 41) | public Continuation(CompletedCallback callback) {
method Continuation (line 44) | public Continuation(CompletedCallback callback, Runnable cancelCallbac...
method wrap (line 49) | private CompletedCallback wrap() {
method reportCompleted (line 69) | void reportCompleted(Exception ex) {
method hook (line 78) | private ContinuationCallback hook(ContinuationCallback callback) {
method add (line 86) | public Continuation add(ContinuationCallback callback) {
method insert (line 91) | public Continuation insert(ContinuationCallback callback) {
method add (line 96) | public Continuation add(final DependentFuture future) {
method next (line 110) | private void next() {
method cancel (line 137) | @Override
method start (line 149) | public Continuation start() {
method onContinue (line 157) | @Override
method run (line 163) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/future/Converter.java
class Converter (line 16) | public class Converter<R> {
method convert (line 17) | public static <T> Converter<T> convert(Future<T> future, String mime) {
method convert (line 21) | public static <T> Converter<T> convert(Future<T> future) {
class MimedData (line 25) | static class MimedData<T> {
method MimedData (line 26) | public MimedData(T data, String mime) {
class MultiTransformer (line 34) | static class MultiTransformer<T, F> extends MultiTransformFuture<Mimed...
method MultiTransformer (line 38) | public MultiTransformer(TypeConverter<T, F> converter, String conver...
method transform (line 44) | @Override
class EnsureHashMap (line 69) | static abstract class EnsureHashMap<K, V> extends LinkedHashMap<K, V> {
method ensure (line 70) | synchronized V ensure(K k) {
method makeDefault (line 77) | protected abstract V makeDefault();
class MimedType (line 80) | static class MimedType<T> {
method MimedType (line 81) | MimedType(Class<T> type, String mime) {
method hashCode (line 88) | @Override
method equals (line 93) | @Override
method isTypeOf (line 100) | public boolean isTypeOf(MimedType other) {
method primary (line 108) | public String primary() {
method secondary (line 112) | public String secondary() {
method isTypeOf (line 117) | public boolean isTypeOf(String mime) {
method toString (line 131) | @Override
class ConverterTransformers (line 137) | static class ConverterTransformers<F, T> extends LinkedHashMap<MimedTy...
class Converters (line 140) | static class Converters<F, T> extends EnsureHashMap<MimedType<F>, Conv...
method makeDefault (line 141) | @Override
method add (line 146) | private static <F, T> void add(ConverterTransformers<F, T> set, Conv...
method getAll (line 151) | public ConverterTransformers<F, T> getAll(MimedType<T> mimedType) {
method getConverters (line 165) | protected ConverterEntries getConverters() {
method Converter (line 171) | protected Converter(Future future, String mime) {
method to (line 178) | synchronized private final <T> Future<T> to(Object value, Class<T> cla...
method to (line 184) | synchronized private final <T> Future<T> to(Class fromClass, Class<T> ...
class PathInfo (line 216) | static class PathInfo {
method distance (line 221) | static int distance(ArrayDeque<PathInfo> path) {
method mimeReplace (line 230) | static String mimeReplace(String mime1, String mime2) {
method to (line 241) | public final <T> Future<T> to(Class<T> clazz) {
method search (line 245) | private <T> boolean search(MimedType<T> target, ArrayDeque<PathInfo> b...
method to (line 291) | public <T> Future<T> to(Class<T> clazz, String mime) {
class ConverterEntry (line 295) | static class ConverterEntry<F, T> {
method ConverterEntry (line 296) | ConverterEntry(Class<F> from, String fromMime, Class<T> to, String t...
method hashCode (line 307) | @Override
method equals (line 312) | @Override
class ConverterEntries (line 319) | public static class ConverterEntries {
method ConverterEntries (line 321) | public ConverterEntries() {
method ConverterEntries (line 324) | public ConverterEntries(ConverterEntries other) {
method addConverter (line 328) | public synchronized <F, T> void addConverter(Class<F> from, String f...
method addConverter (line 331) | public synchronized <F, T> void addConverter(Class<F> from, String f...
method removeConverter (line 340) | public synchronized boolean removeConverter(TypeConverter typeConver...
FILE: AndroidAsync/src/com/koushikdutta/async/future/DependentCancellable.java
type DependentCancellable (line 3) | public interface DependentCancellable extends Cancellable {
method setParent (line 4) | boolean setParent(Cancellable parent);
FILE: AndroidAsync/src/com/koushikdutta/async/future/DependentFuture.java
type DependentFuture (line 3) | public interface DependentFuture<T> extends Future<T>, DependentCancella...
FILE: AndroidAsync/src/com/koushikdutta/async/future/DoneCallback.java
type DoneCallback (line 3) | public interface DoneCallback<T> {
method done (line 4) | void done(Exception e, T result) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/FailCallback.java
type FailCallback (line 3) | public interface FailCallback {
method fail (line 10) | void fail(Exception e) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/FailConvertCallback.java
type FailConvertCallback (line 3) | public interface FailConvertCallback<T> {
method fail (line 11) | T fail(Exception e) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/FailRecoverCallback.java
type FailRecoverCallback (line 3) | public interface FailRecoverCallback<T> {
method fail (line 11) | Future<T> fail(Exception e) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/Future.java
type Future (line 6) | public interface Future<T> extends Cancellable, java.util.concurrent.Fut...
method setCallback (line 12) | void setCallback(FutureCallback<T> callback);
method done (line 22) | Future<T> done(DoneCallback<T> done);
method success (line 30) | Future<T> success(SuccessCallback<T> callback);
method then (line 39) | <R> Future<R> then(ThenFutureCallback<R, T> then);
method thenConvert (line 48) | <R> Future<R> thenConvert(ThenCallback<R, T> then);
method fail (line 57) | Future<T> fail(FailCallback fail);
method failConvert (line 66) | Future<T> failConvert(FailConvertCallback<T> fail);
method failRecover (line 75) | Future<T> failRecover(FailRecoverCallback<T> fail);
method tryGet (line 81) | T tryGet();
method tryGetException (line 87) | Exception tryGetException();
method executorThread (line 94) | default Future<T> executorThread(Executor executor) {
FILE: AndroidAsync/src/com/koushikdutta/async/future/FutureCallback.java
type FutureCallback (line 6) | public interface FutureCallback<T> {
method onCompleted (line 12) | public void onCompleted(Exception e, T result);
FILE: AndroidAsync/src/com/koushikdutta/async/future/FutureRunnable.java
type FutureRunnable (line 6) | public interface FutureRunnable<T> {
method run (line 7) | T run() throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/FutureThread.java
class FutureThread (line 8) | public class FutureThread<T> extends SimpleFuture<T> {
method FutureThread (line 9) | public FutureThread(final FutureRunnable<T> runnable) {
method FutureThread (line 13) | public FutureThread(final ExecutorService pool, final FutureRunnable<T...
method FutureThread (line 27) | public FutureThread(final FutureRunnable<T> runnable, String name) {
FILE: AndroidAsync/src/com/koushikdutta/async/future/Futures.java
class Futures (line 9) | public class Futures {
method waitAll (line 10) | public static <T> Future<List<T>> waitAll(final List<Future<T>> future...
method waitAll (line 38) | public static <T> Future<List<T>> waitAll(final Future<T>... futures) {
method loopUntil (line 43) | private static <T, F> void loopUntil(final Iterator<F> values, ThenFut...
method loopUntil (line 61) | public static <T, F> Future<T> loopUntil(final Iterable<F> values, The...
method loopUntil (line 67) | public static <T, F> Future<T> loopUntil(final F[] values, ThenFutureC...
FILE: AndroidAsync/src/com/koushikdutta/async/future/HandlerFuture.java
class HandlerFuture (line 9) | public class HandlerFuture<T> extends SimpleFuture<T> {
method HandlerFuture (line 12) | public HandlerFuture() {
method setCallback (line 19) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/future/MultiFuture.java
class MultiFuture (line 8) | public class MultiFuture<T> extends SimpleFuture<T> {
method MultiFuture (line 11) | public MultiFuture() {
method MultiFuture (line 14) | public MultiFuture(T value) {
method MultiFuture (line 18) | public MultiFuture(Exception e) {
method MultiFuture (line 22) | public MultiFuture(Future<T> future) {
method setCallbackInternal (line 40) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/future/MultiTransformFuture.java
class MultiTransformFuture (line 3) | public abstract class MultiTransformFuture<T, F> extends MultiFuture<T> ...
method onCompleted (line 4) | @Override
method error (line 21) | protected void error(Exception e) {
method transform (line 25) | protected abstract void transform(F result) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/SimpleCancellable.java
class SimpleCancellable (line 3) | public class SimpleCancellable implements DependentCancellable {
method isDone (line 5) | @Override
method cancelCleanup (line 10) | protected void cancelCleanup() {
method cleanup (line 13) | protected void cleanup() {
method completeCleanup (line 16) | protected void completeCleanup() {
method setComplete (line 19) | public boolean setComplete() {
method cancel (line 35) | @Override
method setParent (line 57) | @Override
method isCancelled (line 67) | @Override
method reset (line 86) | public Cancellable reset() {
FILE: AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java
class SimpleFuture (line 10) | public class SimpleFuture<T> extends SimpleCancellable implements Depend...
type FutureCallbackInternal (line 17) | protected interface FutureCallbackInternal<T> {
method onCompleted (line 18) | void onCompleted(Exception e, T result, FutureCallsite next);
method SimpleFuture (line 21) | public SimpleFuture() {
method SimpleFuture (line 24) | public SimpleFuture(T value) {
method SimpleFuture (line 28) | public SimpleFuture(Exception e) {
method SimpleFuture (line 32) | public SimpleFuture(Future<T> future) {
method cancel (line 36) | @Override
method cancelInternal (line 41) | private boolean cancelInternal(boolean silent) {
method cancelSilently (line 56) | public boolean cancelSilently() {
method cancel (line 60) | @Override
method get (line 65) | @Override
method getResultOrThrow (line 77) | private T getResultOrThrow() throws ExecutionException {
method get (line 83) | @Override
method setComplete (line 96) | @Override
method handleInternalCompleteLocked (line 101) | private FutureCallbackInternal<T> handleInternalCompleteLocked() {
class FutureCallsite (line 113) | static class FutureCallsite {
method loop (line 118) | void loop() {
method handleCallbackUnlocked (line 135) | private void handleCallbackUnlocked(FutureCallsite callsite, FutureCal...
method releaseWaiterLocked (line 156) | void releaseWaiterLocked() {
method ensureWaiterLocked (line 163) | AsyncSemaphore ensureWaiterLocked() {
method setComplete (line 169) | public boolean setComplete(Exception e) {
method setCompleteException (line 172) | public boolean setCompleteException(Exception e) { return setComplete(...
method setComplete (line 174) | public boolean setComplete(T value) {
method setCompleteValue (line 177) | public boolean setCompleteValue(T value) {
method setComplete (line 181) | public boolean setComplete(Exception e, T value) {
method setComplete (line 185) | private boolean setComplete(Exception e, T value, FutureCallsite calls...
method setCallbackInternal (line 199) | void setCallbackInternal(FutureCallsite callsite, FutureCallbackIntern...
method setCallback (line 211) | @Override
method setComplete (line 219) | private Future<T> setComplete(Future<T> future, FutureCallsite callsit...
method setComplete (line 241) | public Future<T> setComplete(Future<T> future) {
method setCompleteFuture (line 245) | public Future<T> setCompleteFuture(Future<T> future) {
method getCallback (line 254) | @Deprecated
method done (line 259) | @Override
method success (line 280) | @Override
method then (line 301) | @Override
method thenConvert (line 324) | @Override
method fail (line 329) | @Override
method failRecover (line 337) | @Override
method failConvert (line 359) | @Override
method setParent (line 364) | @Override
method reset (line 373) | public SimpleFuture<T> reset() {
method tryGetException (line 385) | @Override
method tryGet (line 390) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/future/SuccessCallback.java
type SuccessCallback (line 3) | public interface SuccessCallback<T> {
method success (line 4) | void success(T value) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/ThenCallback.java
type ThenCallback (line 3) | public interface ThenCallback<T, F> {
method then (line 11) | T then(F from) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/ThenFutureCallback.java
type ThenFutureCallback (line 3) | public interface ThenFutureCallback<T, F> {
method then (line 11) | Future<T> then(F from) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/TransformFuture.java
class TransformFuture (line 3) | public abstract class TransformFuture<T, F> extends SimpleFuture<T> impl...
method TransformFuture (line 4) | public TransformFuture(F from) {
method TransformFuture (line 8) | public TransformFuture() {
method onCompleted (line 11) | @Override
method error (line 28) | protected void error(Exception e) {
method transform (line 32) | protected abstract void transform(F result) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/future/TypeConverter.java
type TypeConverter (line 3) | public interface TypeConverter<T, F> {
method convert (line 4) | Future<T> convert(F from, String fromMime) throws Exception;
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java
class AsyncHttpClient (line 49) | public class AsyncHttpClient {
method getDefaultInstance (line 51) | public static AsyncHttpClient getDefaultInstance() {
method getMiddleware (line 59) | public Collection<AsyncHttpClientMiddleware> getMiddleware() {
method insertMiddleware (line 62) | public void insertMiddleware(AsyncHttpClientMiddleware middleware) {
method AsyncHttpClient (line 70) | public AsyncHttpClient(AsyncServer server) {
method setupAndroidProxy (line 78) | @SuppressLint("NewApi")
method getSocketMiddleware (line 114) | public AsyncSocketMiddleware getSocketMiddleware() {
method getSSLSocketMiddleware (line 118) | public AsyncSSLSocketMiddleware getSSLSocketMiddleware() {
method execute (line 122) | public Future<AsyncHttpResponse> execute(final AsyncHttpRequest reques...
method execute (line 128) | public Future<AsyncHttpResponse> execute(String uri, final HttpConnect...
class FutureAsyncHttpResponse (line 133) | private class FutureAsyncHttpResponse extends SimpleFuture<AsyncHttpRe...
method cancel (line 138) | @Override
method reportConnectedCompleted (line 155) | private void reportConnectedCompleted(FutureAsyncHttpResponse cancel, ...
method execute (line 178) | private void execute(final AsyncHttpRequest request, final int redirec...
method getTimeoutRemaining (line 192) | private static long getTimeoutRemaining(AsyncHttpRequest request) {
method copyHeader (line 198) | private static void copyHeader(AsyncHttpRequest from, AsyncHttpRequest...
method executeAffinity (line 204) | private void executeAffinity(final AsyncHttpRequest request, final int...
method executeSocket (line 307) | private void executeSocket(final AsyncHttpRequest request, final int r...
class RequestCallbackBase (line 492) | public static abstract class RequestCallbackBase<T> implements Request...
method onProgress (line 493) | @Override
method onConnect (line 496) | @Override
class DownloadCallback (line 501) | public static abstract class DownloadCallback extends RequestCallbackB...
class StringCallback (line 504) | public static abstract class StringCallback extends RequestCallbackBas...
class JSONObjectCallback (line 507) | public static abstract class JSONObjectCallback extends RequestCallbac...
class JSONArrayCallback (line 510) | public static abstract class JSONArrayCallback extends RequestCallback...
class FileCallback (line 513) | public static abstract class FileCallback extends RequestCallbackBase<...
method executeByteBufferList (line 516) | public Future<ByteBufferList> executeByteBufferList(AsyncHttpRequest r...
method executeString (line 520) | public Future<String> executeString(AsyncHttpRequest req, final String...
method executeJSONObject (line 524) | public Future<JSONObject> executeJSONObject(AsyncHttpRequest req, fina...
method executeJSONArray (line 528) | public Future<JSONArray> executeJSONArray(AsyncHttpRequest req, final ...
method invokeWithAffinity (line 532) | private <T> void invokeWithAffinity(final RequestCallback<T> callback,...
method invoke (line 544) | private <T> void invoke(final RequestCallback<T> callback, final Simpl...
method invokeProgress (line 554) | private void invokeProgress(final RequestCallback callback, final Asyn...
method invokeConnect (line 559) | private void invokeConnect(final RequestCallback callback, final Async...
method executeFile (line 564) | public Future<File> executeFile(AsyncHttpRequest req, final String fil...
method execute (line 645) | public <T> SimpleFuture<T> execute(AsyncHttpRequest req, final AsyncPa...
type WebSocketConnectCallback (line 665) | public interface WebSocketConnectCallback {
method onCompleted (line 666) | void onCompleted(Exception ex, WebSocket webSocket);
method websocket (line 669) | public Future<WebSocket> websocket(final AsyncHttpRequest req, String ...
method websocket (line 673) | public Future<WebSocket> websocket(final AsyncHttpRequest req, String[...
method websocket (line 703) | public Future<WebSocket> websocket(String uri, String protocol, final ...
method websocket (line 708) | public Future<WebSocket> websocket(String uri, String[] protocols, fin...
method getServer (line 713) | public AsyncServer getServer() {
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClientMiddleware.java
type AsyncHttpClientMiddleware (line 15) | public interface AsyncHttpClientMiddleware {
type ResponseHead (line 16) | interface ResponseHead {
method socket (line 17) | AsyncSocket socket();
method protocol (line 18) | String protocol();
method message (line 19) | String message();
method code (line 20) | int code();
method protocol (line 21) | ResponseHead protocol(String protocol);
method message (line 22) | ResponseHead message(String message);
method code (line 23) | ResponseHead code(int code);
method headers (line 24) | Headers headers();
method headers (line 25) | ResponseHead headers(Headers headers);
method sink (line 26) | DataSink sink();
method sink (line 27) | ResponseHead sink(DataSink sink);
method emitter (line 28) | DataEmitter emitter();
method emitter (line 29) | ResponseHead emitter(DataEmitter emitter);
class OnRequestData (line 32) | class OnRequestData {
class GetSocketData (line 37) | class GetSocketData extends OnRequestData {
class OnExchangeHeaderData (line 43) | class OnExchangeHeaderData extends GetSocketData {
class OnRequestSentData (line 50) | class OnRequestSentData extends OnExchangeHeaderData {
class OnHeadersReceivedData (line 53) | class OnHeadersReceivedData extends OnRequestSentData {
class OnBodyDecoderData (line 56) | class OnBodyDecoderData extends OnHeadersReceivedData {
class OnResponseReadyData (line 60) | class OnResponseReadyData extends OnBodyDecoderData {
class OnResponseCompleteData (line 63) | class OnResponseCompleteData extends OnResponseReadyData {
method onRequest (line 71) | void onRequest(OnRequestData data);
method getSocket (line 78) | Cancellable getSocket(GetSocketData data);
method exchangeHeaders (line 86) | boolean exchangeHeaders(OnExchangeHeaderData data);
method onRequestSent (line 93) | void onRequestSent(OnRequestSentData data);
method onHeadersReceived (line 99) | void onHeadersReceived(OnHeadersReceivedData data);
method onBodyDecoder (line 105) | void onBodyDecoder(OnBodyDecoderData data);
method onResponseReady (line 114) | AsyncHttpRequest onResponseReady(OnResponseReadyData data);
method onResponseComplete (line 121) | void onResponseComplete(OnResponseCompleteData data);
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpDelete.java
class AsyncHttpDelete (line 5) | public class AsyncHttpDelete extends AsyncHttpRequest {
method AsyncHttpDelete (line 8) | public AsyncHttpDelete(String uri) {
method AsyncHttpDelete (line 12) | public AsyncHttpDelete(Uri uri) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpGet.java
class AsyncHttpGet (line 5) | public class AsyncHttpGet extends AsyncHttpRequest {
method AsyncHttpGet (line 8) | public AsyncHttpGet(String uri) {
method AsyncHttpGet (line 12) | public AsyncHttpGet(Uri uri) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpHead.java
class AsyncHttpHead (line 8) | public class AsyncHttpHead extends AsyncHttpRequest {
method AsyncHttpHead (line 9) | public AsyncHttpHead(Uri uri) {
method hasBody (line 13) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpPost.java
class AsyncHttpPost (line 5) | public class AsyncHttpPost extends AsyncHttpRequest {
method AsyncHttpPost (line 8) | public AsyncHttpPost(String uri) {
method AsyncHttpPost (line 12) | public AsyncHttpPost(Uri uri) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpPut.java
class AsyncHttpPut (line 5) | public class AsyncHttpPut extends AsyncHttpRequest {
method AsyncHttpPut (line 8) | public AsyncHttpPut(String uri) {
method AsyncHttpPut (line 12) | public AsyncHttpPut(Uri uri) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpRequest.java
class AsyncHttpRequest (line 11) | public class AsyncHttpRequest {
method getRequestLine (line 12) | public RequestLine getRequestLine() {
method hasBody (line 45) | public boolean hasBody() {
method getPath (line 49) | public String getPath() {
method getDefaultUserAgent (line 53) | protected static String getDefaultUserAgent() {
method getMethod (line 60) | public String getMethod() {
method setRequestLineProtocol (line 64) | public void setRequestLineProtocol(String scheme) {
method getRequestLineProtocol (line 68) | public String getRequestLineProtocol() {
method setMethod (line 72) | public AsyncHttpRequest setMethod(String method) {
method AsyncHttpRequest (line 79) | public AsyncHttpRequest(Uri uri, String method) {
method setDefaultHeaders (line 83) | public static void setDefaultHeaders(Headers ret, Uri uri) {
method AsyncHttpRequest (line 99) | public AsyncHttpRequest(Uri uri, String method, Headers headers) {
method getUri (line 111) | public Uri getUri() {
method getHeaders (line 117) | public Headers getHeaders() {
method getFollowRedirect (line 122) | public boolean getFollowRedirect() {
method setFollowRedirect (line 125) | public AsyncHttpRequest setFollowRedirect(boolean follow) {
method setBody (line 131) | public void setBody(AsyncHttpRequestBody body) {
method getBody (line 135) | public AsyncHttpRequestBody getBody() {
method onHandshakeException (line 139) | public void onHandshakeException(AsyncSSLException e) {
method getTimeout (line 144) | public int getTimeout() {
method setTimeout (line 148) | public AsyncHttpRequest setTimeout(int timeout) {
method setHeader (line 153) | public AsyncHttpRequest setHeader(String name, String value) {
method addHeader (line 158) | public AsyncHttpRequest addHeader(String name, String value) {
method enableProxy (line 165) | public void enableProxy(String host, int port) {
method disableProxy (line 170) | public void disableProxy() {
method getProxyHost (line 175) | public String getProxyHost() {
method getProxyPort (line 179) | public int getProxyPort() {
method toString (line 183) | @Override
method setLogging (line 190) | public void setLogging(String tag, int level) {
method getLogLevel (line 197) | public int getLogLevel() {
method getLogTag (line 200) | public String getLogTag() {
method getLogMessage (line 204) | private String getLogMessage(String message) {
method logi (line 212) | public void logi(String message) {
method logv (line 219) | public void logv(String message) {
method logw (line 226) | public void logw(String message) {
method logd (line 233) | public void logd(String message) {
method logd (line 240) | public void logd(String message, Exception e) {
method loge (line 248) | public void loge(String message) {
method loge (line 255) | public void loge(String message, Exception e) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpResponse.java
type AsyncHttpResponse (line 7) | public interface AsyncHttpResponse extends DataEmitter {
method protocol (line 8) | public String protocol();
method message (line 9) | public String message();
method code (line 10) | public int code();
method headers (line 11) | public Headers headers();
method detachSocket (line 12) | public AsyncSocket detachSocket();
method getRequest (line 13) | public AsyncHttpRequest getRequest();
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpResponseImpl.java
class AsyncHttpResponseImpl (line 15) | abstract class AsyncHttpResponseImpl extends FilteredDataEmitter impleme...
method socket (line 16) | public AsyncSocket socket() {
method getRequest (line 20) | @Override
method setSocket (line 25) | void setSocket(AsyncSocket exchange) {
method onHeadersSent (line 33) | protected void onHeadersSent() {
method onRequestCompleted (line 47) | protected void onRequestCompleted(Exception ex) {
method onCompleted (line 51) | @Override
method onHeadersReceived (line 65) | protected void onHeadersReceived() {
method emitter (line 69) | @Override
method emitter (line 74) | @Override
method terminate (line 80) | private void terminate() {
method report (line 93) | @Override
method close (line 104) | @Override
method AsyncHttpResponseImpl (line 113) | public AsyncHttpResponseImpl(AsyncHttpRequest request) {
method headers (line 119) | @Override
method headers (line 124) | @Override
method code (line 131) | @Override
method code (line 136) | @Override
method protocol (line 142) | @Override
method message (line 148) | @Override
method protocol (line 155) | @Override
method message (line 161) | @Override
method toString (line 166) | @Override
method assertContent (line 174) | private void assertContent() {
method sink (line 182) | @Override
method sink (line 187) | @Override
method getServer (line 193) | @Override
method charset (line 198) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncSSLEngineConfigurator.java
type AsyncSSLEngineConfigurator (line 6) | public interface AsyncSSLEngineConfigurator {
method createEngine (line 7) | SSLEngine createEngine(SSLContext sslContext, String peerHost, int pee...
method configureEngine (line 8) | void configureEngine(SSLEngine engine, AsyncHttpClientMiddleware.GetSo...
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncSSLSocketMiddleware.java
class AsyncSSLSocketMiddleware (line 25) | public class AsyncSSLSocketMiddleware extends AsyncSocketMiddleware {
method AsyncSSLSocketMiddleware (line 26) | public AsyncSSLSocketMiddleware(AsyncHttpClient client) {
method setSSLContext (line 32) | public void setSSLContext(SSLContext sslContext) {
method getSSLContext (line 36) | public SSLContext getSSLContext() {
method setTrustManagers (line 42) | public void setTrustManagers(TrustManager[] trustManagers) {
method setHostnameVerifier (line 48) | public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
method addEngineConfigurator (line 54) | public void addEngineConfigurator(AsyncSSLEngineConfigurator engineCon...
method clearEngineConfigurators (line 58) | public void clearEngineConfigurators() {
method createConfiguredSSLEngine (line 62) | protected SSLEngine createConfiguredSSLEngine(GetSocketData data, Stri...
method createHandshakeCallback (line 79) | protected AsyncSSLSocketWrapper.HandshakeCallback createHandshakeCallb...
method tryHandshake (line 88) | protected void tryHandshake(AsyncSocket socket, GetSocketData data, fi...
method wrapCallback (line 95) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/AsyncSocketMiddleware.java
class AsyncSocketMiddleware (line 22) | public class AsyncSocketMiddleware extends SimpleMiddleware {
method AsyncSocketMiddleware (line 28) | public AsyncSocketMiddleware(AsyncHttpClient client, String scheme, in...
method setIdleTimeoutMs (line 34) | public void setIdleTimeoutMs(int idleTimeoutMs) {
method getSchemePort (line 38) | public int getSchemePort(Uri uri) {
method AsyncSocketMiddleware (line 49) | public AsyncSocketMiddleware(AsyncHttpClient client) {
method wrapCallback (line 55) | protected ConnectCallback wrapCallback(GetSocketData data, Uri uri, in...
method getConnectAllAddresses (line 60) | public boolean getConnectAllAddresses() {
method setConnectAllAddresses (line 64) | public void setConnectAllAddresses(boolean connectAllAddresses) {
method disableProxy (line 72) | public void disableProxy() {
method enableProxy (line 78) | public void enableProxy(String host, int port) {
method computeLookup (line 84) | String computeLookup(Uri uri, int port, String proxyHost, int proxyPor...
class IdleSocketHolder (line 97) | class IdleSocketHolder {
method IdleSocketHolder (line 98) | public IdleSocketHolder(AsyncSocket socket) {
class ConnectionInfo (line 105) | static class ConnectionInfo {
method getMaxConnectionCount (line 114) | public int getMaxConnectionCount() {
method setMaxConnectionCount (line 118) | public void setMaxConnectionCount(int maxConnectionCount) {
method getSocket (line 122) | @Override
method getOrCreateConnectionInfo (line 228) | private ConnectionInfo getOrCreateConnectionInfo(String lookup) {
method maybeCleanupConnectionInfo (line 237) | private void maybeCleanupConnectionInfo(String lookup) {
method recycleSocket (line 255) | private void recycleSocket(final AsyncSocket socket, AsyncHttpRequest ...
method idleSocket (line 279) | private void idleSocket(final AsyncSocket socket) {
method nextConnection (line 302) | private void nextConnection(AsyncHttpRequest request) {
method isKeepAlive (line 323) | protected boolean isKeepAlive(OnResponseCompleteData data) {
method onResponseComplete (line 327) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/BasicNameValuePair.java
class BasicNameValuePair (line 104) | public class BasicNameValuePair implements NameValuePair, Cloneable {
method BasicNameValuePair (line 115) | public BasicNameValuePair(final String name, final String value) {
method getName (line 129) | public String getName() {
method getValue (line 138) | public String getValue() {
method toString (line 148) | public String toString() {
method equals (line 152) | public boolean equals(final Object object) {
method hashCode (line 164) | public int hashCode() {
method clone (line 168) | public Object clone() throws CloneNotSupportedException {
FILE: AndroidAsync/src/com/koushikdutta/async/http/BodyDecoderException.java
class BodyDecoderException (line 3) | public class BodyDecoderException extends Exception {
method BodyDecoderException (line 4) | public BodyDecoderException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/ConnectionClosedException.java
class ConnectionClosedException (line 3) | public class ConnectionClosedException extends Exception {
method ConnectionClosedException (line 4) | public ConnectionClosedException(String message) {
method ConnectionClosedException (line 8) | public ConnectionClosedException(String detailMessage, Throwable throw...
FILE: AndroidAsync/src/com/koushikdutta/async/http/ConnectionFailedException.java
class ConnectionFailedException (line 3) | public class ConnectionFailedException extends Exception {
method ConnectionFailedException (line 4) | public ConnectionFailedException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/Headers.java
class Headers (line 16) | public class Headers {
method Headers (line 17) | public Headers() {
method Headers (line 20) | public Headers(Map<String, List<String>> mm) {
method newList (line 27) | @Override
method getMultiMap (line 32) | public Multimap getMultiMap() {
method getAll (line 36) | public List<String> getAll(String header) {
method get (line 40) | public String get(String header) {
method set (line 44) | public Headers set(String header, String value) {
method add (line 54) | public Headers add(String header, String value) {
method addLine (line 62) | public Headers addLine(String line) {
method addAll (line 74) | public Headers addAll(String header, List<String> values) {
method addAll (line 81) | public Headers addAll(Map<String, List<String>> m) {
method addAllMap (line 90) | public Headers addAllMap(Map<String, String> m) {
method addAll (line 97) | public Headers addAll(Headers headers) {
method removeAll (line 103) | public List<String> removeAll(String header) {
method remove (line 107) | public String remove(String header) {
method removeAll (line 114) | public Headers removeAll(Collection<String> headers) {
method toStringBuilder (line 121) | public StringBuilder toStringBuilder() {
method toString (line 136) | @Override
method toPrefixString (line 141) | public String toPrefixString(String prefix) {
method parse (line 148) | public static Headers parse(String payload) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/HttpDate.java
class HttpDate (line 29) | public final class HttpDate {
method initialValue (line 37) | @Override protected DateFormat initialValue() {
method parse (line 71) | public static Date parse(String value) {
method format (line 90) | public static String format(Date value) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/HttpTransportMiddleware.java
class HttpTransportMiddleware (line 20) | public class HttpTransportMiddleware extends SimpleMiddleware {
method exchangeHeaders (line 21) | @Override
method responseIsEmpty (line 138) | static boolean responseIsEmpty(int code) {
method onRequestSent (line 142) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/HttpUtil.java
class HttpUtil (line 17) | public class HttpUtil {
method getBody (line 18) | public static AsyncHttpRequestBody getBody(DataEmitter emitter, Comple...
class EndEmitter (line 44) | static class EndEmitter extends FilteredDataEmitter {
method EndEmitter (line 45) | private EndEmitter() {
method create (line 48) | public static EndEmitter create(AsyncServer server, final Exception ...
method getBodyDecoder (line 62) | public static DataEmitter getBodyDecoder(DataEmitter emitter, Protocol...
method isKeepAlive (line 118) | public static boolean isKeepAlive(Protocol protocol, Headers headers) {
method isKeepAlive (line 126) | public static boolean isKeepAlive(String protocol, Headers headers) {
method contentLength (line 134) | public static long contentLength(Headers headers) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/HybiParser.java
class HybiParser (line 48) | abstract class HybiParser {
method mask (line 109) | private static byte[] mask(byte[] payload, byte[] mask, int offset) {
method inflate (line 118) | private byte[] inflate(byte[] payload) throws DataFormatException {
method setMasking (line 136) | public void setMasking(boolean masking) {
method setDeflate (line 140) | public void setDeflate(boolean deflate) {
method onDataAvailable (line 145) | @Override
method onDataAvailable (line 159) | @Override
method onDataAvailable (line 167) | @Override
method onDataAvailable (line 183) | @Override
method onDataAvailable (line 193) | @Override
method parse (line 209) | void parse() {
method HybiParser (line 246) | public HybiParser(DataEmitter socket) {
method parseOpcode (line 251) | private void parseOpcode(byte data) throws ProtocolError {
method parseLength (line 277) | private void parseLength(byte data) {
method parseExtendedLength (line 289) | private void parseExtendedLength(byte[] buffer) throws ProtocolError {
method frame (line 294) | public byte[] frame(String data) {
method frame (line 298) | public byte[] frame(byte[] data) {
method frame (line 302) | public byte[] frame(byte[] data, int offset, int length) {
method pingFrame (line 306) | public byte[] pingFrame(String data) {
method pongFrame (line 310) | public byte[] pongFrame(String data) {
method frame (line 322) | private byte[] frame(int opcode, byte[] data, int errorCode) {
method frame (line 334) | private byte[] frame(int opcode, String data, int errorCode) {
method frame (line 338) | private byte[] frame(int opcode, byte [] data, int errorCode, int data...
method close (line 390) | public void close(int code, String reason) {
method emitFrame (line 396) | private void emitFrame() throws IOException {
method onMessage (line 458) | protected abstract void onMessage(byte[] payload);
method onMessage (line 459) | protected abstract void onMessage(String payload);
method onPong (line 460) | protected abstract void onPong(String payload);
method onPing (line 461) | protected abstract void onPing(String payload);
method onDisconnect (line 462) | protected abstract void onDisconnect(int code, String reason);
method report (line 463) | protected abstract void report(Exception ex);
method sendFrame (line 465) | protected abstract void sendFrame(byte[] frame);
method reset (line 467) | private void reset() {
method encode (line 472) | private String encode(byte[] buffer) {
method decode (line 480) | private byte[] decode(String string) {
method getInteger (line 488) | private int getInteger(byte[] bytes) throws ProtocolError {
method slice (line 496) | private byte[] slice(byte[] array, int start) {
method finalize (line 502) | @Override
class ProtocolError (line 517) | public static class ProtocolError extends IOException {
method ProtocolError (line 518) | public ProtocolError(String detailMessage) {
method byteArrayToLong (line 523) | private static long byteArrayToLong(byte[] b, int offset, int length) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/Multimap.java
class Multimap (line 19) | public class Multimap extends LinkedHashMap<String, List<String>> implem...
method Multimap (line 20) | public Multimap() {
method newList (line 23) | protected List<String> newList() {
method getString (line 27) | public String getString(String name) {
method getAllString (line 34) | public String getAllString(String name, String delimiter) {
method ensure (line 50) | public List<String> ensure(String name) {
method add (line 59) | public void add(String name, String value) {
method put (line 63) | public void put(String name, String value) {
method Multimap (line 69) | public Multimap(List<NameValuePair> pairs) {
method Multimap (line 74) | public Multimap(Multimap m) {
type StringDecoder (line 78) | public interface StringDecoder {
method decode (line 79) | public String decode(String s);
method parse (line 82) | public static Multimap parse(String value, String delimiter, boolean u...
method parse (line 86) | public static Multimap parse(String value, String delimiter, String as...
method parseSemicolonDelimited (line 111) | public static Multimap parseSemicolonDelimited(String header) {
method parseCommaDelimited (line 115) | public static Multimap parseCommaDelimited(String header) {
method decode (line 120) | @Override
method parseQuery (line 126) | public static Multimap parseQuery(String query) {
method decode (line 131) | @Override
method parseUrlEncoded (line 137) | public static Multimap parseUrlEncoded(String query) {
method iterator (line 141) | @Override
method toSingleMap (line 153) | public Map<String, String> toSingleMap() {
FILE: AndroidAsync/src/com/koushikdutta/async/http/NameValuePair.java
type NameValuePair (line 102) | public interface NameValuePair {
method getName (line 104) | String getName();
method getValue (line 106) | String getValue();
FILE: AndroidAsync/src/com/koushikdutta/async/http/Protocol.java
type Protocol (line 18) | public enum Protocol {
method needsSpdyConnection (line 45) | @Override
method needsSpdyConnection (line 64) | @Override
method Protocol (line 81) | Protocol(String protocol) {
method get (line 88) | public static Protocol get(String protocol) {
method toString (line 98) | @Override
method needsSpdyConnection (line 103) | public boolean needsSpdyConnection() {
FILE: AndroidAsync/src/com/koushikdutta/async/http/ProtocolVersion.java
class ProtocolVersion (line 55) | public class ProtocolVersion implements Serializable, Cloneable {
method ProtocolVersion (line 77) | public ProtocolVersion(String protocol, int major, int minor) {
method getProtocol (line 100) | public final String getProtocol() {
method getMajor (line 109) | public final int getMajor() {
method getMinor (line 118) | public final int getMinor() {
method forVersion (line 138) | public ProtocolVersion forVersion(int major, int minor) {
method hashCode (line 154) | public final int hashCode() {
method equals (line 172) | public final boolean equals(Object obj) {
method isComparable (line 197) | public boolean isComparable(ProtocolVersion that) {
method compareToVersion (line 218) | public int compareToVersion(ProtocolVersion that) {
method greaterEquals (line 247) | public final boolean greaterEquals(ProtocolVersion version) {
method lessEquals (line 262) | public final boolean lessEquals(ProtocolVersion version) {
method toString (line 272) | public String toString() {
method clone (line 282) | public Object clone() throws CloneNotSupportedException {
FILE: AndroidAsync/src/com/koushikdutta/async/http/RedirectLimitExceededException.java
class RedirectLimitExceededException (line 3) | public class RedirectLimitExceededException extends Exception {
method RedirectLimitExceededException (line 4) | public RedirectLimitExceededException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/RequestLine.java
type RequestLine (line 45) | public interface RequestLine {
method getMethod (line 47) | String getMethod();
method getProtocolVersion (line 49) | ProtocolVersion getProtocolVersion();
method getUri (line 51) | String getUri();
FILE: AndroidAsync/src/com/koushikdutta/async/http/SSLEngineSNIConfigurator.java
class SSLEngineSNIConfigurator (line 14) | public class SSLEngineSNIConfigurator implements AsyncSSLEngineConfigura...
class EngineHolder (line 15) | private static class EngineHolder implements AsyncSSLEngineConfigurator {
method createEngine (line 22) | @Override
method EngineHolder (line 27) | public EngineHolder(Class engineClass) {
method configureEngine (line 45) | @Override
method createEngine (line 62) | @Override
method ensureHolder (line 75) | EngineHolder ensureHolder(SSLEngine engine) {
method configureEngine (line 85) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/SimpleMiddleware.java
class SimpleMiddleware (line 5) | public class SimpleMiddleware implements AsyncHttpClientMiddleware {
method onRequest (line 6) | @Override
method getSocket (line 10) | @Override
method exchangeHeaders (line 15) | @Override
method onRequestSent (line 20) | @Override
method onHeadersReceived (line 24) | @Override
method onBodyDecoder (line 28) | @Override
method onResponseReady (line 32) | @Override
method onResponseComplete (line 37) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/WebSocket.java
type WebSocket (line 5) | public interface WebSocket extends AsyncSocket {
type StringCallback (line 6) | interface StringCallback {
method onStringAvailable (line 7) | void onStringAvailable(String s);
type PingCallback (line 9) | interface PingCallback {
method onPingReceived (line 10) | void onPingReceived(String s);
type PongCallback (line 12) | interface PongCallback {
method onPongReceived (line 13) | void onPongReceived(String s);
method send (line 16) | void send(byte[] bytes);
method send (line 17) | void send(String string);
method send (line 18) | void send(byte [] bytes, int offset, int len);
method ping (line 19) | void ping(String message);
method pong (line 20) | void pong(String message);
method setStringCallback (line 22) | void setStringCallback(StringCallback callback);
method getStringCallback (line 23) | StringCallback getStringCallback();
method setPingCallback (line 25) | void setPingCallback(PingCallback callback);
method setPongCallback (line 27) | void setPongCallback(PongCallback callback);
method getPongCallback (line 28) | PongCallback getPongCallback();
method isBuffering (line 30) | boolean isBuffering();
method getProtocol (line 31) | String getProtocol();
method getSocket (line 33) | AsyncSocket getSocket();
FILE: AndroidAsync/src/com/koushikdutta/async/http/WebSocketHandshakeException.java
class WebSocketHandshakeException (line 3) | public class WebSocketHandshakeException extends Exception {
method WebSocketHandshakeException (line 4) | public WebSocketHandshakeException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/WebSocketImpl.java
class WebSocketImpl (line 23) | public class WebSocketImpl implements WebSocket {
method end (line 24) | @Override
method toByteArray (line 29) | private static byte[] toByteArray(UUID uuid) {
method SHA1 (line 37) | private static String SHA1(String text) {
method addAndEmit (line 53) | private void addAndEmit(ByteBufferList bb) {
method setupParser (line 73) | private void setupParser(boolean masking, boolean deflate) {
method WebSocketImpl (line 121) | public WebSocketImpl(AsyncHttpServerRequest request, AsyncHttpServerRe...
method getProtocol (line 145) | @Override
method addWebSocketUpgradeHeaders (line 150) | public static void addWebSocketUpgradeHeaders(AsyncHttpRequest req, St...
method WebSocketImpl (line 169) | public WebSocketImpl(AsyncSocket socket) {
method finishHandshake (line 174) | public static WebSocket finishHandshake(Headers requestHeaders, AsyncH...
method close (line 211) | @Override
method setClosedCallback (line 216) | @Override
method getClosedCallback (line 221) | @Override
method setEndCallback (line 227) | @Override
method getEndCallback (line 232) | @Override
method send (line 237) | @Override
method send (line 242) | @Override
method send (line 247) | @Override
method ping (line 252) | @Override
method pong (line 257) | @Override
method setStringCallback (line 263) | @Override
method setDataCallback (line 269) | @Override
method getStringCallback (line 274) | @Override
method setPingCallback (line 280) | @Override
method setPongCallback (line 286) | @Override
method getPongCallback (line 291) | @Override
method getDataCallback (line 296) | @Override
method isOpen (line 301) | @Override
method isBuffering (line 306) | @Override
method write (line 311) | @Override
method setWriteableCallback (line 317) | @Override
method getWriteableCallback (line 322) | @Override
method getSocket (line 327) | @Override
method getServer (line 332) | @Override
method isChunked (line 337) | @Override
method pause (line 342) | @Override
method resume (line 347) | @Override
method isPaused (line 352) | @Override
method charset (line 357) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/AsyncHttpRequestBody.java
type AsyncHttpRequestBody (line 8) | public interface AsyncHttpRequestBody<T> {
method write (line 9) | public void write(AsyncHttpRequest request, DataSink sink, CompletedCa...
method parse (line 10) | public void parse(DataEmitter emitter, CompletedCallback completed);
method getContentType (line 11) | public String getContentType();
method readFullyOnRequest (line 12) | public boolean readFullyOnRequest();
method length (line 13) | public int length();
method get (line 14) | public T get();
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/ByteBufferListRequestBody.java
class ByteBufferListRequestBody (line 11) | public class ByteBufferListRequestBody implements AsyncHttpRequestBody<B...
method ByteBufferListRequestBody (line 12) | public ByteBufferListRequestBody() {
method ByteBufferListRequestBody (line 16) | public ByteBufferListRequestBody(ByteBufferList bb) {
method write (line 19) | @Override
method parse (line 24) | @Override
method getContentType (line 34) | @Override
method readFullyOnRequest (line 39) | @Override
method length (line 44) | @Override
method get (line 49) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/DocumentBody.java
class DocumentBody (line 25) | public class DocumentBody implements AsyncHttpRequestBody<Document> {
method DocumentBody (line 26) | public DocumentBody() {
method DocumentBody (line 30) | public DocumentBody(Document document) {
method prepare (line 35) | private void prepare() {
method write (line 53) | @Override
method parse (line 60) | @Override
method getContentType (line 73) | @Override
method readFullyOnRequest (line 78) | @Override
method length (line 83) | @Override
method get (line 90) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/FileBody.java
class FileBody (line 14) | public class FileBody implements AsyncHttpRequestBody<File> {
method FileBody (line 20) | public FileBody(File file) {
method FileBody (line 24) | public FileBody(File file, String contentType) {
method write (line 29) | @Override
method parse (line 34) | @Override
method getContentType (line 39) | @Override
method setContentType (line 44) | public void setContentType(String contentType) {
method readFullyOnRequest (line 48) | @Override
method length (line 53) | @Override
method get (line 58) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/FilePart.java
class FilePart (line 12) | public class FilePart extends StreamPart {
method FilePart (line 14) | public FilePart(String name, final File file) {
method getInputStream (line 26) | @Override
method toString (line 31) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/JSONArrayBody.java
class JSONArrayBody (line 13) | public class JSONArrayBody implements AsyncHttpRequestBody<JSONArray> {
method JSONArrayBody (line 14) | public JSONArrayBody() {
method JSONArrayBody (line 19) | public JSONArrayBody(JSONArray json) {
method parse (line 24) | @Override
method write (line 35) | @Override
method getContentType (line 40) | @Override
method readFullyOnRequest (line 45) | @Override
method length (line 50) | @Override
method get (line 58) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/JSONObjectBody.java
class JSONObjectBody (line 13) | public class JSONObjectBody implements AsyncHttpRequestBody<JSONObject> {
method JSONObjectBody (line 14) | public JSONObjectBody() {
method JSONObjectBody (line 19) | public JSONObjectBody(JSONObject json) {
method parse (line 24) | @Override
method write (line 35) | @Override
method getContentType (line 40) | @Override
method readFullyOnRequest (line 45) | @Override
method length (line 50) | @Override
method get (line 58) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/MultipartFormDataBody.java
class MultipartFormDataBody (line 24) | public class MultipartFormDataBody extends BoundaryEmitter implements As...
type MultipartCallback (line 30) | public interface MultipartCallback {
method onPart (line 31) | public void onPart(Part part);
method parse (line 34) | @Override
method handleLast (line 40) | void handleLast() {
method getField (line 59) | public String getField(String name) {
method onBoundaryEnd (line 65) | @Override
method onBoundaryStart (line 71) | @Override
method MultipartFormDataBody (line 113) | public MultipartFormDataBody(String contentType) {
method setMultipartCallback (line 123) | public void setMultipartCallback(MultipartCallback callback) {
method getMultipartCallback (line 127) | public MultipartCallback getMultipartCallback() {
method write (line 132) | @Override
method getContentType (line 186) | @Override
method readFullyOnRequest (line 194) | @Override
method length (line 200) | @Override
method MultipartFormDataBody (line 217) | public MultipartFormDataBody() {
method setContentType (line 220) | public void setContentType(String contentType) {
method getParts (line 224) | public List<Part> getParts() {
method addFilePart (line 230) | public void addFilePart(String name, File file) {
method addStringPart (line 234) | public void addStringPart(String name, String value) {
method addPart (line 239) | public void addPart(Part part) {
method get (line 245) | @Override
method toString (line 250) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/Part.java
class Part (line 13) | public class Part {
method Part (line 18) | public Part(Headers headers) {
method getName (line 23) | public String getName() {
method Part (line 28) | public Part(String name, long length, List<NameValuePair> contentDispo...
method getRawHeaders (line 41) | public Headers getRawHeaders() {
method getContentType (line 45) | public String getContentType() {
method setContentType (line 49) | public void setContentType(String contentType) {
method getFilename (line 53) | public String getFilename() {
method isFile (line 60) | public boolean isFile() {
method length (line 64) | public long length() {
method write (line 68) | public void write(DataSink sink, CompletedCallback callback) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/StreamBody.java
class StreamBody (line 11) | public class StreamBody implements AsyncHttpRequestBody<InputStream> {
method StreamBody (line 21) | public StreamBody(InputStream stream, int length) {
method write (line 26) | @Override
method parse (line 31) | @Override
method getContentType (line 37) | @Override
method setContentType (line 41) | public StreamBody setContentType(String contentType) {
method readFullyOnRequest (line 46) | @Override
method length (line 51) | @Override
method get (line 56) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/StreamPart.java
class StreamPart (line 11) | public abstract class StreamPart extends Part {
method StreamPart (line 12) | public StreamPart(String name, long length, List<NameValuePair> conten...
method write (line 16) | @Override
method getInputStream (line 27) | protected abstract InputStream getInputStream() throws IOException;
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/StringBody.java
class StringBody (line 11) | public class StringBody implements AsyncHttpRequestBody<String> {
method StringBody (line 12) | public StringBody() {
method StringBody (line 17) | public StringBody(String string) {
method parse (line 22) | @Override
method write (line 35) | @Override
method getContentType (line 42) | @Override
method readFullyOnRequest (line 47) | @Override
method length (line 52) | @Override
method toString (line 59) | @Override
method get (line 64) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/StringPart.java
class StringPart (line 7) | public class StringPart extends StreamPart {
method StringPart (line 9) | public StringPart(String name, String value) {
method getInputStream (line 14) | @Override
method getValue (line 19) | public String getValue() {
method toString (line 23) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/body/UrlEncodedFormBody.java
class UrlEncodedFormBody (line 18) | public class UrlEncodedFormBody implements AsyncHttpRequestBody<Multimap> {
method UrlEncodedFormBody (line 22) | public UrlEncodedFormBody(Multimap parameters) {
method UrlEncodedFormBody (line 26) | public UrlEncodedFormBody(List<NameValuePair> parameters) {
method buildData (line 30) | private void buildData() {
method write (line 52) | @Override
method getContentType (line 60) | @Override
method parse (line 65) | @Override
method UrlEncodedFormBody (line 91) | public UrlEncodedFormBody() {
method readFullyOnRequest (line 94) | @Override
method length (line 99) | @Override
method get (line 106) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/HeaderParser.java
class HeaderParser (line 19) | final class HeaderParser {
type CacheControlHandler (line 21) | public interface CacheControlHandler {
method handle (line 22) | void handle(String directive, String parameter);
method parseCacheControl (line 28) | public static void parseCacheControl(String value, CacheControlHandler...
method skipUntil (line 72) | private static int skipUntil(String input, int pos, String characters) {
method skipWhitespace (line 85) | private static int skipWhitespace(String input, int pos) {
method parseSeconds (line 99) | public static int parseSeconds(String value) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/Objects.java
class Objects (line 19) | final class Objects {
method Objects (line 20) | private Objects() {}
method equal (line 25) | public static boolean equal(Object a, Object b) {
method hashCode (line 29) | public static int hashCode(Object o) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/RawHeaders.java
class RawHeaders (line 47) | final class RawHeaders {
method compare (line 49) | @Override public int compare(String a, String b) {
method RawHeaders (line 68) | public RawHeaders() {}
method RawHeaders (line 70) | public RawHeaders(RawHeaders copyFrom) {
method copy (line 74) | public void copy(RawHeaders copyFrom) {
method setStatusLine (line 86) | public void setStatusLine(String statusLine) {
method getStatusLine (line 111) | public String getStatusLine() {
method getHttpMinorVersion (line 119) | public int getHttpMinorVersion() {
method getResponseCode (line 126) | public int getResponseCode() {
method getResponseMessage (line 133) | public String getResponseMessage() {
method addLine (line 141) | public void addLine(String line) {
method add (line 153) | public void add(String fieldName, String value) {
method removeAll (line 170) | public void removeAll(String fieldName) {
method addAll (line 179) | public void addAll(String fieldName, List<String> headerFields) {
method set (line 189) | public void set(String fieldName, String value) {
method length (line 197) | public int length() {
method getFieldName (line 204) | public String getFieldName(int index) {
method getValue (line 215) | public String getValue(int index) {
method get (line 226) | public String get(String fieldName) {
method getAll (line 238) | public RawHeaders getAll(Set<String> fieldNames) {
method toHeaderString (line 249) | public String toHeaderString() {
method toMultimap (line 264) | public Map<String, List<String>> toMultimap() {
method fromMultimap (line 289) | public static RawHeaders fromMultimap(Map<String, List<String>> map) {
method parse (line 303) | public static RawHeaders parse(String payload) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/RequestHeaders.java
class RequestHeaders (line 30) | final class RequestHeaders {
method RequestHeaders (line 67) | public RequestHeaders(Uri uri, RawHeaders headers) {
method isChunked (line 125) | public boolean isChunked() {
method hasConnectionClose (line 129) | public boolean hasConnectionClose() {
method getUri (line 133) | public Uri getUri() {
method getHeaders (line 137) | public RawHeaders getHeaders() {
method isNoCache (line 141) | public boolean isNoCache() {
method getMaxAgeSeconds (line 145) | public int getMaxAgeSeconds() {
method getMaxStaleSeconds (line 149) | public int getMaxStaleSeconds() {
method getMinFreshSeconds (line 153) | public int getMinFreshSeconds() {
method isOnlyIfCached (line 157) | public boolean isOnlyIfCached() {
method hasAuthorization (line 161) | public boolean hasAuthorization() {
method getContentLength (line 165) | public int getContentLength() {
method getTransferEncoding (line 169) | public String getTransferEncoding() {
method getUserAgent (line 173) | public String getUserAgent() {
method getHost (line 177) | public String getHost() {
method getConnection (line 181) | public String getConnection() {
method getAcceptEncoding (line 185) | public String getAcceptEncoding() {
method getContentType (line 189) | public String getContentType() {
method getIfModifiedSince (line 193) | public String getIfModifiedSince() {
method getIfNoneMatch (line 197) | public String getIfNoneMatch() {
method getProxyAuthorization (line 201) | public String getProxyAuthorization() {
method setChunked (line 205) | public void setChunked() {
method setContentLength (line 213) | public void setContentLength(int contentLength) {
method setUserAgent (line 223) | public void setUserAgent(String userAgent) {
method setHost (line 231) | public void setHost(String host) {
method setConnection (line 239) | public void setConnection(String connection) {
method setAcceptEncoding (line 247) | public void setAcceptEncoding(String acceptEncoding) {
method setContentType (line 255) | public void setContentType(String contentType) {
method setIfModifiedSince (line 263) | public void setIfModifiedSince(Date date) {
method setIfNoneMatch (line 272) | public void setIfNoneMatch(String ifNoneMatch) {
method hasConditions (line 285) | public boolean hasConditions() {
method addCookies (line 289) | public void addCookies(Map<String, List<String>> allCookieHeaders) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/ResponseCacheMiddleware.java
class ResponseCacheMiddleware (line 51) | public class ResponseCacheMiddleware extends SimpleMiddleware {
method ResponseCacheMiddleware (line 69) | private ResponseCacheMiddleware() {
method addCache (line 72) | public static ResponseCacheMiddleware addCache(AsyncHttpClient client,...
method getFileCache (line 84) | public FileCache getFileCache() {
method getCaching (line 88) | public boolean getCaching() {
method setCaching (line 92) | public void setCaching(boolean caching) {
method removeFromCache (line 96) | public void removeFromCache(Uri uri) {
method getSocket (line 103) | @Override
method getConditionalCacheHitCount (line 206) | public int getConditionalCacheHitCount() {
method getCacheHitCount (line 210) | public int getCacheHitCount() {
method getNetworkCount (line 214) | public int getNetworkCount() {
method getCacheStoreCount (line 218) | public int getCacheStoreCount() {
method onBodyDecoder (line 224) | @Override
method onResponseComplete (line 303) | @Override
method clear (line 322) | public void clear() {
class CacheData (line 328) | public static class CacheData {
class BodyCacher (line 335) | private static class BodyCacher extends FilteredDataEmitter {
method report (line 339) | @Override
method onDataAvailable (line 346) | @Override
method close (line 393) | @Override
method abort (line 399) | public void abort() {
method commit (line 406) | public void commit() {
class CachedBodyEmitter (line 414) | private static class CachedBodyEmitter extends FilteredDataEmitter {
method CachedBodyEmitter (line 420) | public CachedBodyEmitter(EntryCacheResponse cacheResponse, long cont...
method run (line 426) | @Override
method sendCachedDataOnNetworkThread (line 432) | void sendCachedDataOnNetworkThread() {
method sendCachedData (line 467) | void sendCachedData() {
method resume (line 471) | @Override
method isPaused (line 477) | @Override
method close (line 482) | @Override
method report (line 499) | @Override
class Entry (line 510) | private static final class Entry {
method Entry (line 565) | public Entry(InputStream in) throws IOException {
method Entry (line 602) | public Entry(Uri uri, RawHeaders varyHeaders, AsyncHttpRequest reque...
method writeTo (line 625) | public void writeTo(EntryEditor editor) throws IOException {
method isHttps (line 653) | private boolean isHttps() {
method readCertArray (line 657) | private Certificate[] readCertArray(StrictLineReader reader) throws ...
method writeCertArray (line 677) | private void writeCertArray(Writer writer, Certificate[] certificate...
method matches (line 694) | public boolean matches(Uri uri, String requestMethod,
class EntryCacheResponse (line 703) | static class EntryCacheResponse extends CacheResponse {
method EntryCacheResponse (line 707) | public EntryCacheResponse(Entry entry, FileInputStream snapshot) {
method getHeaders (line 712) | @Override public Map<String, List<String>> getHeaders() {
method getBody (line 716) | @Override public FileInputStream getBody() {
class CachedSSLSocket (line 721) | private class CachedSSLSocket extends CachedSocket implements AsyncSSL...
method CachedSSLSocket (line 722) | public CachedSSLSocket(EntryCacheResponse cacheResponse, long conten...
method getSSLEngine (line 726) | @Override
method getPeerCertificates (line 731) | @Override
class CachedSocket (line 737) | private class CachedSocket extends CachedBodyEmitter implements AsyncS...
method CachedSocket (line 741) | public CachedSocket(EntryCacheResponse cacheResponse, long contentLe...
method end (line 746) | @Override
method report (line 750) | @Override
method write (line 760) | @Override
method getWriteableCallback (line 766) | @Override
method setWriteableCallback (line 771) | @Override
method isOpen (line 775) | @Override
method close (line 780) | @Override
method getClosedCallback (line 785) | @Override
method setClosedCallback (line 790) | @Override
method getServer (line 795) | @Override
class EntryEditor (line 801) | class EntryEditor {
method EntryEditor (line 806) | public EntryEditor(String key) {
method commit (line 812) | void commit() {
method newOutputStream (line 821) | FileOutputStream newOutputStream(int index) throws IOException {
method abort (line 827) | void abort() {
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/ResponseHeaders.java
class ResponseHeaders (line 36) | final class ResponseHeaders {
method ResponseHeaders (line 117) | public ResponseHeaders(Uri uri, RawHeaders headers) {
method isContentEncodingGzip (line 189) | public boolean isContentEncodingGzip() {
method stripContentEncoding (line 193) | public void stripContentEncoding() {
method isChunked (line 198) | public boolean isChunked() {
method hasConnectionClose (line 202) | public boolean hasConnectionClose() {
method getUri (line 206) | public Uri getUri() {
method getHeaders (line 210) | public RawHeaders getHeaders() {
method getServedDate (line 214) | public Date getServedDate() {
method getLastModified (line 218) | public Date getLastModified() {
method getExpires (line 222) | public Date getExpires() {
method isNoCache (line 226) | public boolean isNoCache() {
method isNoStore (line 230) | public boolean isNoStore() {
method getMaxAgeSeconds (line 234) | public int getMaxAgeSeconds() {
method getSMaxAgeSeconds (line 238) | public int getSMaxAgeSeconds() {
method isPublic (line 242) | public boolean isPublic() {
method isMustRevalidate (line 246) | public boolean isMustRevalidate() {
method getEtag (line 250) | public String getEtag() {
method getVaryFields (line 254) | public Set<String> getVaryFields() {
method getContentEncoding (line 258) | public String getContentEncoding() {
method getContentLength (line 262) | public long getContentLength() {
method getConnection (line 266) | public String getConnection() {
method getProxyAuthenticate (line 270) | public String getProxyAuthenticate() {
method getWwwAuthenticate (line 274) | public String getWwwAuthenticate() {
method setLocalTimestamps (line 278) | public void setLocalTimestamps(long sentRequestMillis, long receivedRe...
method computeAge (line 289) | private long computeAge(long nowMillis) {
method computeFreshnessLifetime (line 305) | private long computeFreshnessLifetime() {
method isFreshnessLifetimeHeuristic (line 331) | private boolean isFreshnessLifetimeHeuristic() {
method isCacheable (line 339) | public boolean isCacheable(RequestHeaders request) {
method hasVaryAll (line 375) | public boolean hasVaryAll() {
method varyMatches (line 383) | public boolean varyMatches(Map<String, List<String>> cachedRequest,
method chooseResponseSource (line 396) | public ResponseSource chooseResponseSource(long nowMillis, RequestHead...
method validate (line 461) | public boolean validate(ResponseHeaders networkResponse) {
method combine (line 484) | public ResponseHeaders combine(ResponseHeaders network) {
method isEndToEnd (line 512) | private static boolean isEndToEnd(String fieldName) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/ResponseSource.java
type ResponseSource (line 19) | enum ResponseSource {
method requiresConnection (line 37) | public boolean requiresConnection() {
FILE: AndroidAsync/src/com/koushikdutta/async/http/cache/StrictLineReader.java
class StrictLineReader (line 46) | class StrictLineReader implements Closeable {
method StrictLineReader (line 68) | public StrictLineReader(InputStream in) {
method StrictLineReader (line 80) | public StrictLineReader(InputStream in, int capacity) {
method StrictLineReader (line 93) | public StrictLineReader(InputStream in, Charset charset) {
method StrictLineReader (line 108) | public StrictLineReader(InputStream in, int capacity, Charset charset) {
method close (line 131) | @Override
method readLine (line 149) | public String readLine() throws IOException {
method readInt (line 206) | public int readInt() throws IOException {
method hasUnterminatedLine (line 221) | public boolean hasUnterminatedLine() {
method fillBuf (line 232) | private void fillBuf() throws IOException {
FILE: AndroidAsync/src/com/koushikdutta/async/http/callback/HttpConnectCallback.java
type HttpConnectCallback (line 6) | public interface HttpConnectCallback {
method onConnectCompleted (line 7) | public void onConnectCompleted(Exception ex, AsyncHttpResponse response);
FILE: AndroidAsync/src/com/koushikdutta/async/http/callback/RequestCallback.java
type RequestCallback (line 6) | public interface RequestCallback<T> extends ResultCallback<AsyncHttpResp...
method onConnect (line 7) | public void onConnect(AsyncHttpResponse response);
method onProgress (line 8) | public void onProgress(AsyncHttpResponse response, long downloaded, lo...
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/ChunkedDataException.java
class ChunkedDataException (line 3) | public class ChunkedDataException extends Exception {
method ChunkedDataException (line 4) | public ChunkedDataException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/ChunkedInputFilter.java
class ChunkedInputFilter (line 8) | public class ChunkedInputFilter extends FilteredDataEmitter {
type State (line 13) | private enum State {
method checkByte (line 24) | private boolean checkByte(char b, char value) {
method checkLF (line 33) | private boolean checkLF(char b) {
method checkCR (line 37) | private boolean checkCR(char b) {
method report (line 41) | @Override
method onDataAvailable (line 49) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/ChunkedOutputFilter.java
class ChunkedOutputFilter (line 9) | public class ChunkedOutputFilter extends FilteredDataSink {
method ChunkedOutputFilter (line 10) | public ChunkedOutputFilter(DataSink sink) {
method filter (line 14) | @Override
method end (line 22) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/ContentLengthFilter.java
class ContentLengthFilter (line 7) | public class ContentLengthFilter extends FilteredDataEmitter {
method ContentLengthFilter (line 8) | public ContentLengthFilter(long contentLength) {
method report (line 12) | @Override
method onDataAvailable (line 22) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/DataRemainingException.java
class DataRemainingException (line 3) | public class DataRemainingException extends Exception {
method DataRemainingException (line 4) | public DataRemainingException(String message, Exception cause) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/GZIPInputFilter.java
class GZIPInputFilter (line 17) | public class GZIPInputFilter extends InflaterInputFilter {
method peekShort (line 18) | static short peekShort(byte[] src, int offset, ByteOrder order) {
method GZIPInputFilter (line 36) | public GZIPInputFilter() {
method unsignedToBytes (line 43) | public static int unsignedToBytes(byte b) {
method onDataAvailable (line 47) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/InflaterInputFilter.java
class InflaterInputFilter (line 12) | public class InflaterInputFilter extends FilteredDataEmitter {
method report (line 15) | @Override
method onDataAvailable (line 25) | @Override
method InflaterInputFilter (line 59) | public InflaterInputFilter() {
method InflaterInputFilter (line 63) | public InflaterInputFilter(Inflater inflater) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/filter/PrematureDataEndException.java
class PrematureDataEndException (line 3) | public class PrematureDataEndException extends Exception {
method PrematureDataEndException (line 4) | public PrematureDataEndException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpRequestBodyProvider.java
type AsyncHttpRequestBodyProvider (line 6) | public interface AsyncHttpRequestBodyProvider {
method getBody (line 7) | AsyncHttpRequestBody getBody(Headers headers);
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServer.java
class AsyncHttpServer (line 30) | @TargetApi(Build.VERSION_CODES.ECLAIR)
method stop (line 33) | public void stop() {
method onRequest (line 41) | protected boolean onRequest(AsyncHttpServerRequest request, AsyncHttpS...
method onResponseCompleted (line 45) | protected void onResponseCompleted(AsyncHttpServerRequest request, Asy...
method onRequest (line 49) | protected void onRequest(HttpServerRequestCallback callback, AsyncHttp...
method isKeepAlive (line 62) | protected boolean isKeepAlive(AsyncHttpServerRequest request, AsyncHtt...
method onUnknownBody (line 66) | protected AsyncHttpRequestBody onUnknownBody(Headers headers) {
method isSwitchingProtocols (line 70) | protected boolean isSwitchingProtocols(AsyncHttpServerResponse res) {
method onAccepted (line 75) | @Override
method onCompleted (line 260) | @Override
method onListening (line 265) | @Override
method listen (line 271) | public AsyncServerSocket listen(AsyncServer server, int port) {
method report (line 275) | private void report(Exception ex) {
method listen (line 280) | public AsyncServerSocket listen(int port) {
method listenSecure (line 284) | public void listenSecure(final int port, final SSLContext sslContext) {
method getListenCallback (line 310) | public ListenCallback getListenCallback() {
method setErrorCallback (line 315) | public void setErrorCallback(CompletedCallback callback) {
method getErrorCallback (line 319) | public CompletedCallback getErrorCallback() {
method getResponseCodeDescription (line 338) | public static String getResponseCodeDescription(int code) {
method addResponseCodeDescription (line 345) | public static void addResponseCodeDescription( int code, String descri...
type WebSocketRequestCallback (line 349) | public static interface WebSocketRequestCallback {
method onConnected (line 350) | void onConnected(WebSocket webSocket, AsyncHttpServerRequest request);
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerRequest.java
type AsyncHttpServerRequest (line 12) | public interface AsyncHttpServerRequest extends DataEmitter {
method getHeaders (line 13) | Headers getHeaders();
method getMatcher (line 14) | Matcher getMatcher();
method setMatcher (line 15) | void setMatcher(Matcher matcher);
method getBody (line 16) | <T extends AsyncHttpRequestBody> T getBody();
method getSocket (line 17) | AsyncSocket getSocket();
method getPath (line 18) | String getPath();
method getQuery (line 19) | Multimap getQuery();
method getMethod (line 20) | String getMethod();
method getUrl (line 21) | String getUrl();
method get (line 23) | String get(String name);
method getState (line 24) | Map<String, Object> getState();
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerRequestImpl.java
class AsyncHttpServerRequestImpl (line 21) | public abstract class AsyncHttpServerRequestImpl extends FilteredDataEmi...
method getState (line 27) | @Override
method getStatusLine (line 32) | public String getStatusLine() {
method onCompleted (line 37) | @Override
method onCompleted (line 43) | @Override
method onHeadersReceived (line 50) | abstract protected void onHeadersReceived();
method onNotHttp (line 52) | protected void onNotHttp() {
method onUnknownBody (line 56) | protected AsyncHttpRequestBody onUnknownBody(Headers headers) {
method onBody (line 59) | protected AsyncHttpRequestBody onBody(Headers headers) {
method onStringAvailable (line 65) | @Override
method getMethod (line 98) | @Override
method setSocket (line 103) | void setSocket(AsyncSocket socket) {
method getSocket (line 112) | @Override
method getHeaders (line 117) | @Override
method setDataCallback (line 122) | @Override
method getDataCallback (line 127) | @Override
method isChunked (line 132) | @Override
method getBody (line 138) | @Override
method pause (line 143) | @Override
method resume (line 148) | @Override
method isPaused (line 153) | @Override
method toString (line 158) | @Override
method get (line 165) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponse.java
type AsyncHttpServerResponse (line 19) | public interface AsyncHttpServerResponse extends DataSink, CompletedCall...
method end (line 20) | void end();
method send (line 21) | void send(String contentType, byte[] bytes);
method send (line 22) | void send(String contentType, ByteBufferList bb);
method send (line 23) | void send(String contentType, ByteBuffer bb);
method send (line 24) | void send(String contentType, String string);
method send (line 25) | void send(String string);
method send (line 26) | void send(JSONObject json);
method send (line 27) | void send(JSONArray jsonArray);
method sendFile (line 28) | void sendFile(File file);
method sendStream (line 29) | void sendStream(InputStream inputStream, long totalLength);
method sendBody (line 30) | <T> void sendBody(AsyncParser<T> body, T value);
method code (line 31) | AsyncHttpServerResponse code(int code);
method code (line 32) | int code();
method getHeaders (line 33) | Headers getHeaders();
method writeHead (line 34) | void writeHead();
method setContentType (line 35) | void setContentType(String contentType);
method redirect (line 36) | void redirect(String location);
method getRequest (line 37) | AsyncHttpServerRequest getRequest();
method getHttpVersion (line 38) | String getHttpVersion();
method setHttpVersion (line 39) | void setHttpVersion(String httpVersion);
method proxy (line 42) | void proxy(AsyncHttpResponse response);
method onCompleted (line 47) | void onCompleted(Exception ex);
method getSocket (line 48) | AsyncSocket getSocket();
method setSocket (line 49) | void setSocket(AsyncSocket socket);
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java
class AsyncHttpServerResponseImpl (line 34) | public class AsyncHttpServerResponseImpl implements AsyncHttpServerRespo...
method getHeaders (line 38) | @Override
method getSocket (line 43) | public AsyncSocket getSocket() {
method setSocket (line 47) | @Override
method AsyncHttpServerResponseImpl (line 54) | AsyncHttpServerResponseImpl(AsyncSocket socket, AsyncHttpServerRequest...
method getRequest (line 61) | @Override
method write (line 66) | @Override
method initFirstWrite (line 87) | void initFirstWrite() {
method setWriteableCallback (line 147) | @Override
method getWriteableCallback (line 155) | @Override
method end (line 163) | @Override
method writeHead (line 195) | @Override
method setContentType (line 200) | @Override
method send (line 205) | @Override
method sendBody (line 210) | @Override
method send (line 216) | @Override
method send (line 221) | @Override
method send (line 233) | @Override
method onEnd (line 244) | protected void onEnd() {
method report (line 248) | protected void report(Exception e) {
method send (line 252) | @Override
method send (line 260) | @Override
method send (line 265) | @Override
method sendStream (line 270) | @Override
method sendFile (line 335) | @Override
method proxy (line 349) | @Override
method code (line 366) | @Override
method code (line 372) | @Override
method redirect (line 377) | @Override
method getHttpVersion (line 385) | @Override
method setHttpVersion (line 390) | @Override
method onCompleted (line 395) | @Override
method isOpen (line 400) | @Override
method setClosedCallback (line 408) | @Override
method getClosedCallback (line 416) | @Override
method getServer (line 423) | @Override
method toString (line 428) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerRouter.java
class AsyncHttpServerRouter (line 33) | public class AsyncHttpServerRouter implements RouteMatcher {
class RouteInfo (line 35) | private static class RouteInfo {
method removeAction (line 44) | public void removeAction(String action, String regex) {
method addAction (line 54) | public void addAction(String action, String regex, HttpServerRequestCa...
method addAction (line 66) | public void addAction(String action, String regex, HttpServerRequestCa...
method websocket (line 70) | public void websocket(String regex, final AsyncHttpServer.WebSocketReq...
method checkWebSocketUpgrade (line 74) | static public WebSocket checkWebSocketUpgrade(final String protocol, A...
method websocket (line 96) | public void websocket(String regex, final String protocol, final Async...
method get (line 109) | public void get(String regex, HttpServerRequestCallback callback) {
method post (line 113) | public void post(String regex, HttpServerRequestCallback callback) {
class Asset (line 117) | public static class Asset {
method Asset (line 118) | public Asset(int available, InputStream inputStream, String path) {
method getAssetStream (line 129) | public static Asset getAssetStream(final Context context, String asset) {
method getAssetStream (line 133) | public static Asset getAssetStream(AssetManager am, String asset) {
method getContentType (line 169) | public static String getContentType(String path) {
method ensureManifest (line 181) | static synchronized Manifest ensureManifest(Context context) {
method isClientCached (line 205) | static boolean isClientCached(Context context, AsyncHttpServerRequest ...
method directory (line 226) | public void directory(Context context, String regex, final String asse...
method directory (line 277) | public void directory(String regex, final File directory) {
method directory (line 281) | public void directory(String regex, final File directory, final boolea...
class RouteMatch (line 341) | public static class RouteMatch {
method RouteMatch (line 348) | private RouteMatch(String method, String path, Matcher matcher, Http...
class AsyncHttpServerRequestImpl (line 357) | abstract class AsyncHttpServerRequestImpl extends com.koushikdutta.asy...
method getMatcher (line 359) | @Override
method setMatcher (line 364) | @Override
class Callback (line 370) | class Callback implements HttpServerRequestCallback, RouteMatcher {
method onRequest (line 371) | @Override
method route (line 383) | @Override
method getCallback (line 391) | public HttpServerRequestCallback getCallback() {
method route (line 395) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/AsyncProxyServer.java
class AsyncProxyServer (line 16) | public class AsyncProxyServer extends AsyncHttpServer {
method AsyncProxyServer (line 18) | public AsyncProxyServer(AsyncServer server) {
method onRequest (line 22) | @Override
method onRequest (line 68) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/BoundaryEmitter.java
class BoundaryEmitter (line 9) | public class BoundaryEmitter extends FilteredDataEmitter {
method setBoundary (line 11) | public void setBoundary(String boundary) {
method getBoundary (line 15) | public String getBoundary() {
method getBoundaryStart (line 21) | public String getBoundaryStart() {
method getBoundaryEnd (line 25) | public String getBoundaryEnd() {
method onBoundaryStart (line 29) | protected void onBoundaryStart() {
method onBoundaryEnd (line 32) | protected void onBoundaryEnd() {
method onDataAvailable (line 70) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/HttpServerRequestCallback.java
type HttpServerRequestCallback (line 4) | public interface HttpServerRequestCallback {
method onRequest (line 5) | public void onRequest(AsyncHttpServerRequest request, AsyncHttpServerR...
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/MalformedRangeException.java
class MalformedRangeException (line 3) | public class MalformedRangeException extends Exception {
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/MimeEncodingException.java
class MimeEncodingException (line 3) | public class MimeEncodingException extends Exception {
method MimeEncodingException (line 4) | public MimeEncodingException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/RouteMatcher.java
type RouteMatcher (line 3) | public interface RouteMatcher {
method route (line 4) | AsyncHttpServerRouter.RouteMatch route(String method, String path);
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/StreamSkipException.java
class StreamSkipException (line 3) | public class StreamSkipException extends Exception {
method StreamSkipException (line 4) | public StreamSkipException(String message) {
FILE: AndroidAsync/src/com/koushikdutta/async/http/server/UnknownRequestBody.java
class UnknownRequestBody (line 11) | public class UnknownRequestBody implements AsyncHttpRequestBody<Void> {
method UnknownRequestBody (line 12) | public UnknownRequestBody(String contentType) {
method UnknownRequestBody (line 17) | public UnknownRequestBody(DataEmitter emitter, String contentType, int...
method write (line 23) | @Override
method getContentType (line 31) | @Override
method readFullyOnRequest (line 36) | @Override
method length (line 41) | @Override
method get (line 46) | @Override
method setCallbacks (line 51) | @Deprecated
method getEmitter (line 57) | public DataEmitter getEmitter() {
method parse (line 62) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/parser/AsyncParser.java
type AsyncParser (line 13) | public interface AsyncParser<T> {
method parse (line 14) | Future<T> parse(DataEmitter emitter);
method write (line 15) | void write(DataSink sink, T value, CompletedCallback completed);
method getType (line 16) | Type getType();
method getMime (line 17) | String getMime();
FILE: AndroidAsync/src/com/koushikdutta/async/parser/ByteBufferListParser.java
class ByteBufferListParser (line 17) | public class ByteBufferListParser implements AsyncParser<ByteBufferList> {
method parse (line 18) | @Override
method write (line 54) | @Override
method getType (line 59) | @Override
method getMime (line 64) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/parser/DocumentParser.java
class DocumentParser (line 19) | public class DocumentParser implements AsyncParser<Document> {
method parse (line 20) | @Override
method write (line 26) | @Override
method getType (line 31) | @Override
method getMime (line 36) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/parser/JSONArrayParser.java
class JSONArrayParser (line 15) | public class JSONArrayParser implements AsyncParser<JSONArray> {
method parse (line 16) | @Override
method write (line 22) | @Override
method getType (line 27) | @Override
method getMime (line 32) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/parser/JSONObjectParser.java
class JSONObjectParser (line 15) | public class JSONObjectParser implements AsyncParser<JSONObject> {
method parse (line 16) | @Override
method write (line 21) | @Override
method getType (line 26) | @Override
method getMime (line 31) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/parser/StringParser.java
class StringParser (line 15) | public class StringParser implements AsyncParser<String> {
method StringParser (line 18) | public StringParser() {
method StringParser (line 21) | public StringParser(Charset charset) {
method parse (line 25) | @Override
method write (line 37) | @Override
method getType (line 42) | @Override
method getMime (line 47) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/stream/ByteBufferListInputStream.java
class ByteBufferListInputStream (line 11) | public class ByteBufferListInputStream extends InputStream {
method ByteBufferListInputStream (line 13) | public ByteBufferListInputStream(ByteBufferList bb) {
method read (line 17) | @Override
method read (line 24) | @Override
method read (line 29) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/stream/FileDataSink.java
class FileDataSink (line 13) | public class FileDataSink extends OutputStreamDataSink {
method FileDataSink (line 15) | public FileDataSink(AsyncServer server, File file) {
method getOutputStream (line 20) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/stream/InputStreamDataEmitter.java
class InputStreamDataEmitter (line 19) | public class InputStreamDataEmitter implements DataEmitter {
method InputStreamDataEmitter (line 22) | public InputStreamDataEmitter(AsyncServer server, InputStream inputStr...
method setDataCallback (line 29) | @Override
method getDataCallback (line 34) | @Override
method isChunked (line 39) | @Override
method pause (line 45) | @Override
method resume (line 50) | @Override
method report (line 56) | private void report(final Exception e) {
method run (line 76) | @Override
method doResume (line 115) | private void doResume() {
method isPaused (line 119) | @Override
method setEndCallback (line 125) | @Override
method getEndCallback (line 130) | @Override
method getServer (line 135) | @Override
method close (line 140) | @Override
method charset (line 150) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/stream/OutputStreamDataCallback.java
class OutputStreamDataCallback (line 12) | public class OutputStreamDataCallback implements DataCallback, Completed...
method OutputStreamDataCallback (line 14) | public OutputStreamDataCallback(OutputStream os) {
method getOutputStream (line 18) | public OutputStream getOutputStream() {
method onDataAvailable (line 22) | @Override
method close (line 39) | public void close() {
method onCompleted (line 48) | @Override
FILE: AndroidAsync/src/com/koushikdutta/async/stream/OutputStreamDataSink.java
class OutputStreamDataSink (line 13) | public class OutputStreamDataSink implements DataSink {
method OutputStreamDataSink (line 14) | public OutputStreamDataSink(AsyncServer server) {
method end (line 18) | @Override
method OutputStreamDataSink (line 31) | public OutputStreamDataSink(AsyncServer server, OutputStream stream) {
method setOutputStream (line 37) | public void setOutputStream(OutputStream stream) {
method getOutputStream (line 41) | public OutputStream getOutputStream() throws IOException {
method write (line 45) | @Override
method setWriteableCallback (line 63) | @Override
method getWriteableCallback (line 68) | @Override
method isOpen (line 73) | @Override
method reportClose (line 80) | public void reportClose(Exception ex) {
method setClosedCallback (line 91) | @Override
method getClosedCallback (line 96) | @Override
method getServer (line 101) | @Override
method setOutputStreamWritableCallback (line 107) | public void setOutputStreamWritableCallback(WritableCallback outputStr...
FILE: AndroidAsync/src/com/koushikdutta/async/util/Allocator.java
class Allocator (line 10) | public class Allocator {
method Allocator (line 15) | public Allocator(int maxAlloc) {
method Allocator (line 19) | public Allocator() {
method allocate (line 23) | public ByteBuffer allocate() {
method allocate (line 27) | public ByteBuffer allocate(int currentAlloc) {
method track (line 31) | public void track(long read) {
method getMaxAlloc (line 35) | public int getMaxAlloc() {
method setCurrentAlloc (line 39) | public void setCurrentAlloc(int currentAlloc) {
method getMinAlloc (line 43) | public int getMinAlloc() {
method setMinAlloc (line 47) | public Allocator setMinAlloc(int minAlloc ) {
FILE: AndroidAsync/src/com/koushikdutta/async/util/ArrayDeque.java
class ArrayDeque (line 59) | public class ArrayDeque<E> extends AbstractCollection<E>
method allocateElements (line 100) | private void allocateElements(int numElements) {
method doubleCapacity (line 123) | private void doubleCapacity() {
method copyElements (line 145) | private <T> T[] copyElements(T[] a) {
method ArrayDeque (line 160) | public ArrayDeque() {
method ArrayDeque (line 170) | public ArrayDeque(int numElements) {
method ArrayDeque (line 184) | public ArrayDeque(Collection<? extends E> c) {
method addFirst (line 199) | public void addFirst(E e) {
method addLast (line 215) | public void addLast(E e) {
method offerFirst (line 230) | public boolean offerFirst(E e) {
method offerLast (line 242) | public boolean offerLast(E e) {
method removeFirst (line 250) | public E removeFirst() {
method removeLast (line 260) | public E removeLast() {
method pollFirst (line 267) | public E pollFirst() {
method pollLast (line 278) | public E pollLast() {
method getFirst (line 291) | public E getFirst() {
method getLast (line 301) | public E getLast() {
method peekFirst (line 309) | public E peekFirst() {
method peekLast (line 315) | public E peekLast() {
method removeFirstOccurrence (line 333) | public boolean removeFirstOccurrence(Object o) {
method removeLastOccurrence (line 361) | public boolean removeLastOccurrence(Object o) {
method add (line 388) | public boolean add(E e) {
method offer (line 402) | public boolean offer(E e) {
method remove (line 417) | public E remove() {
method poll (line 431) | public E poll() {
method element (line 445) | public E element() {
method peek (line 458) | public E peek() {
method push (line 473) | public void push(E e) {
method pop (line 487) | public E pop() {
method checkInvariants (line 491) | private void checkInvariants() {
method delete (line 504) | private boolean delete(int i) {
method size (line 550) | public int size() {
method isEmpty (line 559) | public boolean isEmpty() {
method iterator (line 571) | public Iterator<E> iterator() {
method descendingIterator (line 575) | public Iterator<E> descendingIterator() {
class DeqIterator (line 579) | private class DeqIterator implements Iterator<E> {
method hasNext (line 597) | public boolean hasNext() {
method next (line 601) | public E next() {
method remove (line 614) | public void remove() {
class DescendingIterator (line 625) | private class DescendingIterator implements Iterator<E> {
method hasNext (line 635) | public boolean hasNext() {
method next (line 639) | public E next() {
method remove (line 650) | public void remove() {
method contains (line 669) | public boolean contains(Object o) {
method remove (line 696) | public boolean remove(Object o) {
method clear (line 704) | public void clear() {
method toArray (line 731) | public Object[] toArray() {
method toArray (line 771) | @SuppressWarnings("unchecked")
method clone (line 790) | public ArrayDeque<E> clone() {
method writeObject (line 814) | private void writeObject(java.io.ObjectOutputStream s)
method readObject (line 830) | private void readObject(java.io.ObjectInputStream s)
FILE: AndroidAsync/src/com/koushikdutta/async/util/Charsets.java
class Charsets (line 6) | public class Charsets {
FILE: AndroidAsync/src/com/koushikdutta/async/util/Deque.java
type Deque (line 168) | public interface Deque<E> extends Queue<E> {
method addFirst (line 185) | void addFirst(E e);
method addLast (line 205) | void addLast(E e);
method offerFirst (line 223) | boolean offerFirst(E e);
method offerLast (line 241) | boolean offerLast(E e);
method removeFirst (line 251) | E removeFirst();
method removeLast (line 261) | E removeLast();
method pollFirst (line 269) | E pollFirst();
method pollLast (line 277) | E pollLast();
method getFirst (line 288) | E getFirst();
method getLast (line 298) | E getLast();
method peekFirst (line 306) | E peekFirst();
method peekLast (line 314) | E peekLast();
method removeFirstOccurrence (line 332) | boolean removeFirstOccurrence(Object o);
method removeLastOccurrence (line 350) | boolean removeLastOccurrence(Object o);
method add (line 376) | boolean add(E e);
method offer (line 399) | boolean offer(E e);
method remove (line 412) | E remove();
method poll (line 424) | E poll();
method element (line 437) | E element();
method peek (line 449) | E peek();
method push (line 473) | void push(E e);
method pop (line 485) | E pop();
method remove (line 508) | boolean remove(Object o);
method contains (line 523) | boolean contains(Object o);
method size (line 530) | public int size();
method iterator (line 538) | Iterator<E> iterator();
method descendingIterator (line 548) | Iterator<E> descendingIterator();
FILE: AndroidAsync/src/com/koushikdutta/async/util/FileCache.java
class FileCache (line 21) | public class FileCache {
class CacheEntry (line 22) | class CacheEntry {
method CacheEntry (line 24) | public CacheEntry(File file) {
class Snapshot (line 29) | public static class Snapshot {
method Snapshot (line 32) | Snapshot(FileInputStream[] fins, long[] lens) {
method getLength (line 37) | public long getLength(int index) {
method close (line 41) | public void close() {
method findAlternativeMessageDigest (line 48) | private static MessageDigest findAlternativeMessageDigest() {
method toKeyString (line 81) | public static synchronized String toKeyString(Object... parts) {
method getTempFile (line 92) | public File getTempFile() {
method getTempFiles (line 98) | public File[] getTempFiles(int count) {
method removeFiles (line 106) | public static void removeFiles(File... files) {
method remove (line 114) | public void remove(String key) {
method exists (line 122) | public boolean exists(String key, int part) {
method exists (line 126) | public boolean exists(String key) {
method touch (line 130) | public File touch(File file) {
method get (line 136) | public FileInputStream get(String key) throws IOException {
method getFile (line 140) | public File getFile(String key) {
method get (line 144) | public FileInputStream[] get(String key, int count) throws IOException {
method getPartName (line 163) | String getPartName(String key, int part) {
method commitTempFiles (line 167) | public void commitTempFiles(String key, File... tempFiles) {
method removePartFiles (line 185) | void removePartFiles(String key) {
method getPartFile (line 194) | File getPartFile(String key, int part) {
method setBlockSize (line 199) | public void setBlockSize(long blockSize) {
class InternalCache (line 203) | class InternalCache extends LruCache<String, CacheEntry> {
method InternalCache (line 204) | public InternalCache() {
method sizeOf (line 208) | @Override
method entryRemoved (line 213) | @Override
method compare (line 229) | @Override
method load (line 242) | void load() {
method doLoad (line 264) | private void doLoad() {
method FileCache (line 278) | public FileCache(File directory, long size, boolean loadAsync) {
method size (line 288) | public long size() {
method clear (line 292) | public void clear() {
method keySet (line 297) | public Set<String> keySet() {
method setMaxSize (line 311) | public void setMaxSize(long maxSize) {
FILE: AndroidAsync/src/com/koushikdutta/async/util/FileUtility.java
class FileUtility (line 8) | public class FileUtility {
method deleteDirectory (line 9) | static public boolean deleteDirectory(File path) {
FILE: AndroidAsync/src/com/koushikdutta/async/util/HashList.java
class HashList (line 10) | public class HashList<T> {
method HashList (line 13) | public HashList() {
method keySet (line 16) | public Set<String> keySet() {
method tag (line 20) | public synchronized <V> V tag(String key) {
method tag (line 27) | public synchronized <V> void tag(String key, V tag) {
method remove (line 36) | public synchronized ArrayList<T> remove(String key) {
method size (line 40) | public synchronized int size() {
method get (line 44) | public synchronized ArrayList<T> get(String key) {
method contains (line 48) | synchronized public boolean contains(String key) {
method add (line 53) | synchronized public void add(String key, T value) {
method pop (line 63) | synchronized public T pop(String key) {
method removeItem (line 72) | synchronized public boolean removeItem(String key, T value) {
FILE: AndroidAsync/src/com/koushikdutta/async/util/IdleTimeout.java
class IdleTimeout (line 7) | public class IdleTimeout extends TimeoutBase {
method IdleTimeout (line 10) | public IdleTimeout(AsyncServer server, long delay) {
method IdleTimeout (line 15) | public IdleTimeout(Handler handler, long delay) {
method setTimeout (line 19) | public void setTimeout(Runnable callback) {
method reset (line 24) | public void reset() {
method cancel (line 29) | public void cancel() {
FILE: AndroidAsync/src/com/koushikdutta/async/util/LruCache.java
class LruCache (line 30) | public class LruCache<K, V> {
method LruCache (line 48) | public LruCache(long maxSize) {
method get (line 62) | public final V get(K key) {
method put (line 116) | public final V put(K key, V value) {
method trimToSize (line 143) | private void trimToSize(long maxSize) {
method remove (line 174) | public final V remove(K key) {
method entryRemoved (line 209) | protected void entryRemoved(boolean evicted, K key, V oldValue, V newV...
method create (line 226) | protected V create(K key) {
method safeSizeOf (line 230) | private long safeSizeOf(K key, V value) {
method sizeOf (line 245) | protected long sizeOf(K key, V value) {
method evictAll (line 252) | public final void evictAll() {
method size (line 261) | public synchronized final long size() {
method setMaxSize (line 265) | public void setMaxSize(long maxSize) {
method maxSize (line 274) | public synchronized final long maxSize() {
method hitCount (line 281) | public synchronized final int hitCount() {
method missCount (line 289) | public synchronized final int missCount() {
method createCount (line 296) | public synchronized final int createCount() {
method putCount (line 303) | public synchronized final int putCount() {
method evictionCount (line 310) | public synchronized final int evictionCount() {
method snapshot (line 318) | public synchronized final Map<K, V> snapshot() {
method toString (line 322) | @Override public synchronized final String toString() {
FILE: AndroidAsync/src/com/koushikdutta/async/util/StreamUtility.java
class StreamUtility (line 18) | public class StreamUtility {
method fastChannelCopy (line 19) | public static void fastChannelCopy(final ReadableByteChannel src, fina...
method copyStream (line 38) | public static void copyStream(InputStream input, OutputStream output) ...
method readToEndAsArray (line 46) | public static byte[] readToEndAsArray(InputStream input) throws IOExce...
method readToEnd (line 60) | public static String readToEnd(InputStream input) throws IOException
method readFile (line 65) | static public String readFile(String filename) throws IOException {
method readFileSilent (line 69) | static public String readFileSilent(String filename) {
method readFile (line 78) | static public String readFile(File file) throws IOException {
method writeFile (line 90) | public static void writeFile(File file, String string) throws IOExcept...
method writeFile (line 97) | public static void writeFile(String file, String string) throws IOExce...
method closeQuietly (line 101) | public static void closeQuietly(Closeable... closeables) {
method eat (line 118) | public static void eat(InputStream input) throws IOException {
FILE: AndroidAsync/src/com/koushikdutta/async/util/TaggedList.java
class TaggedList (line 5) | public class TaggedList<T> extends ArrayList<T> {
method tag (line 8) | public synchronized <V> V tag() {
method tag (line 12) | public synchronized <V> void tag(V tag) {
method tagNull (line 16) | public synchronized <V> void tagNull(V tag) {
FILE: AndroidAsync/src/com/koushikdutta/async/util/ThrottleTimeout.java
class ThrottleTimeout (line 14) | public class ThrottleTimeout<T> extends TimeoutBase {
type ThrottleMode (line 19) | public enum ThrottleMode {
method ThrottleTimeout (line 33) | public ThrottleTimeout(final AsyncServer server, long delay, ValueCall...
method ThrottleTimeout (line 38) | public ThrottleTimeout(final Handler handler, long delay, ValueCallbac...
method setCallback (line 43) | public void setCallback(ValueCallback<List<T>> callback) {
method runCallback (line 47) | private void runCallback() {
method postThrottled (line 55) | public synchronized void postThrottled(final T value) {
method setThrottleMode (line 76) | public void setThrottleMode(ThrottleMode throttleMode) {
FILE: AndroidAsync/src/com/koushikdutta/async/util/TimeoutBase.java
class TimeoutBase (line 8) | public class TimeoutBase {
type Handlerish (line 12) | interface Handlerish {
method post (line 13) | void post(Runnable r);
method postDelayed (line 14) | Object postDelayed(Runnable r, long delay);
method removeAllCallbacks (line 15) | void removeAllCallbacks(Object cancellable);
method onCallback (line 18) | protected void onCallback() {
method TimeoutBase (line 22) | public TimeoutBase(final AsyncServer server, long delay) {
method TimeoutBase (line 44) | public TimeoutBase(final Handler handler, long delay) {
method setDelay (line 67) | public void setDelay(long delay) {
FILE: AndroidAsync/src/com/koushikdutta/async/util/UntypedHashtable.java
class UntypedHashtable (line 5) | public class UntypedHashtable {
method put (line 8) | public void put(String key, Object value) {
method remove (line 12) | public void remove(String key) {
method get (line 16) | public <T> T get(String key, T defaultValue) {
method get (line 23) | public <T> T get(String key) {
FILE: AndroidAsync/src/com/koushikdutta/async/wrapper/AsyncSocketWrapper.java
type AsyncSocketWrapper (line 5) | public interface AsyncSocketWrapper extends AsyncSocket, DataEmitterWrap...
method getSocket (line 6) | public AsyncSocket getSocket();
FILE: AndroidAsync/src/com/koushikdutta/async/wrapper/DataEmitterWrapper.java
type DataEmitterWrapper (line 5) | public interface DataEmitterWrapper extends DataEmitter {
method getDataEmitter (line 6) | public DataEmitter getDataEmitter();
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/BodyTests.java
class BodyTests (line 14) | @RunWith(AndroidJUnit4.class)
method testNullValue (line 16) | @Test
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/ByteUtilTests.java
class ByteUtilTests (line 15) | public class ByteUtilTests extends TestCase {
method testPushParserUntil (line 17) | public void testPushParserUntil() {
method testPushParserTapUntil (line 37) | public void testPushParserTapUntil() {
method testTapCallback (line 62) | public void testTapCallback() {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/CacheTests.java
class CacheTests (line 40) | @RunWith(AndroidJUnit4.class)
method testMaxAgePrivate (line 42) | public void testMaxAgePrivate() throws Exception {
method test304 (line 76) | @Test
method testFilteredDataEmitter (line 101) | public void testFilteredDataEmitter() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/CallbackTests.java
class CallbackTests (line 31) | @RunWith(AndroidJUnit4.class)
method testThrow (line 33) | @Test
method testHttpServerThrow (line 79) | @Test
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/ConscryptTests.java
class ConscryptTests (line 44) | @RunWith(AndroidJUnit4.class)
method configure (line 57) | private void configure(SSLEngine engine, String host, int port) throws...
method concatLengthPrefixed (line 97) | static byte[] concatLengthPrefixed(String... protocols) {
method testConscryptSSLEngineNPNHandshakeBug (line 109) | public void testConscryptSSLEngineNPNHandshakeBug() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/ConvertTests.java
class ConvertTests (line 16) | @RunWith(AndroidJUnit4.class)
method testConvert (line 18) | @Test
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/DnsTests.java
class DnsTests (line 30) | public class DnsTests extends TestCase {
method testLookup (line 31) | public void testLookup() throws Exception {
method testMulticastLookup (line 44) | public void testMulticastLookup() throws Exception {
method testNoDomain (line 78) | public void testNoDomain() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/FileCacheTests.java
class FileCacheTests (line 23) | @RunWith(AndroidJUnit4.class)
method setUp (line 25) | protected void setUp() throws Exception {
method testSimple (line 34) | public void testSimple() throws Exception {
method testEviction (line 49) | public void testEviction() throws Exception {
method testMultipleParts (line 73) | public void testMultipleParts() throws Exception {
method testMultipartEviction (line 95) | public void testMultipartEviction() throws Exception {
method testMultipartEvictionAgain (line 125) | public void testMultipartEvictionAgain() throws Exception {
method testReinit (line 169) | public void testReinit() throws Exception {
method testCacheOrder (line 194) | public void testCacheOrder() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/FileTests.java
class FileTests (line 26) | @RunWith(AndroidJUnit4.class)
method testFileDataEmitter (line 29) | public void testFileDataEmitter() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/FutureTests.java
class FutureTests (line 29) | @RunWith(AndroidJUnit4.class)
method testChain (line 31) | @Test
method multifutureTest (line 65) | @Test
class IntegerFuture (line 74) | private static class IntegerFuture extends SimpleFuture<Integer> {
method IntegerFuture (line 75) | private IntegerFuture() {
method create (line 78) | public static IntegerFuture create(final int value, final long timeo...
method testFutureCallback (line 99) | @Test
method testFutureFinishedCallback (line 115) | @Test
method testFutureCancel (line 132) | @Test
method testIntegerFuture (line 164) | @Test
method testContinuation (line 171) | @Test
method testFutureChain (line 225) | @Test
method testContinuationFail (line 253) | @Test
method testContinuationCancel (line 280) | @Test
method testChildContinuationCancel (line 325) | @Test
method testContinuationArray (line 379) | public void testContinuationArray() throws Exception {
method testReentrancy (line 414) | @Test
method testPostCancelCallback (line 470) | @Test
method testPreCancelCallback (line 486) | @Test
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/HttpClientTests.java
class HttpClientTests (line 50) | @RunWith(AndroidJUnit4.class)
method finalize (line 55) | @Override
method testHomepage (line 109) | @Test
method testClockworkMod (line 115) | @Test
method testGithubRandomData (line 147) | public void testGithubRandomData() throws Exception {
method testGithubRandomDataWithFuture (line 179) | public void testGithubRandomDataWithFuture() throws Exception {
method testSni (line 186) | public void testSni() throws Exception {
method testGithubHelloWithFuture (line 198) | public void testGithubHelloWithFuture() throws Exception {
method testGithubHelloWithFutureCallback (line 203) | public void testGithubHelloWithFutureCallback() throws Exception {
method testCancel (line 217) | public void testCancel() throws Exception {
method testCache (line 245) | public void testCache() throws Exception {
method testFileCancel (line 262) | public void testFileCancel() throws Exception {
method testProxy (line 298) | public void testProxy() throws Exception {
method testUriPathWithSpaces (line 328) | public void testUriPathWithSpaces() throws Exception {
method testHEAD (line 334) | public void testHEAD() throws Exception {
method testPostJsonObject (line 340) | public void testPostJsonObject() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/HttpServerTests.java
class HttpServerTests (line 26) | public class HttpServerTests extends TestCase {
method setUp (line 29) | @Override
method testJSONObject (line 83) | public void testJSONObject() throws Exception {
method testString (line 93) | public void testString() throws Exception {
method testServerHello (line 113) | public void testServerHello() throws Exception {
method testServerHelloAgain (line 124) | public void testServerHelloAgain() throws Exception {
method tearDown (line 135) | @Override
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/Issue59.java
class Issue59 (line 23) | public class Issue59 extends TestCase {
method testIssue (line 24) | public void testIssue() throws Exception {
method testIon428 (line 58) | public void testIon428() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/IssueWithWebSocketFuturesTests.java
class IssueWithWebSocketFuturesTests (line 14) | public class IssueWithWebSocketFuturesTests extends TestCase {
method testWebSocketFutureWithHandshakeFailureCallback (line 17) | public void testWebSocketFutureWithHandshakeFailureCallback() throws E...
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/LineEmitterTests.java
class LineEmitterTests (line 16) | public class LineEmitterTests extends TestCase {
method testFunnyCharacter (line 17) | public void testFunnyCharacter() {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/Md5.java
class Md5 (line 10) | public class Md5 {
method createInstance (line 12) | public static Md5 createInstance() throws NoSuchAlgorithmException {
method Md5 (line 18) | private Md5() {
method update (line 21) | public void update(ByteBufferList bb) {
method digest (line 28) | public String digest() {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/MultipartTests.java
class MultipartTests (line 33) | @RunWith(AndroidJUnit4.class)
method setUp (line 37) | protected void setUp() throws Exception {
method tearDown (line 78) | protected void tearDown() throws Exception {
method testUpload (line 84) | public void testUpload() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/ParserTests.java
class ParserTests (line 20) | public class ParserTests extends TestCase {
method testString (line 21) | public void testString() throws Exception {
method testUtf8String (line 38) | public void testUtf8String() throws Exception {
method testAsyncParserBase (line 60) | public void testAsyncParserBase() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/ProxyTests.java
class ProxyTests (line 15) | public class ProxyTests extends TestCase {
method disabledTestSSLProxy (line 16) | private void disabledTestSSLProxy() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/RedirectTests.java
class RedirectTests (line 16) | public class RedirectTests extends TestCase {
method setUp (line 17) | @Override
method tearDown (line 61) | @Override
method testRelativeRedirect (line 67) | public void testRelativeRedirect() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/SSLTests.java
class SSLTests (line 27) | @RunWith(AndroidJUnit4.class)
method testKeys (line 29) | public void testKeys() throws Exception {
method disabled__testClientCertificateIssue163 (line 61) | public void disabled__testClientCertificateIssue163() throws Exception {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/SanityChecks.java
class SanityChecks (line 11) | public class SanityChecks extends TestCase {
method testByteOrder (line 12) | public void testByteOrder() {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/TimeoutTests.java
class TimeoutTests (line 25) | public class TimeoutTests extends TestCase {
method TimeoutTests (line 26) | public TimeoutTests() {
method setUp (line 50) | @Override
method tearDown (line 56) | @Override
method testTimeout (line 63) | public void testTimeout() throws Exception {
method testSlowBody (line 79) | public void testSlowBody() throws Exception {
class DelayedStringBody (line 100) | class DelayedStringBody extends StringBody {
method DelayedStringBody (line 101) | public DelayedStringBody(String value) {
method write (line 104) | @Override
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/TriggerFuture.java
class TriggerFuture (line 5) | class TriggerFuture extends SimpleFuture<Integer> {
method trigger (line 6) | public void trigger() {
FILE: AndroidAsync/test/src/com/koushikdutta/async/test/WebSocketTests.java
class WebSocketTests (line 21) | public class WebSocketTests extends TestCase {
method setUp (line 24) | @Override
method testWebSocket (line 52) | @Test
method tearDown (line 91) | @Override
FILE: AndroidAsyncSample/src/com/koushikdutta/async/sample/MainActivity.java
class MainActivity (line 32) | public class MainActivity extends Activity {
method onCreate (line 40) | @SuppressLint("NewApi")
method showCacheToast (line 72) | void showCacheToast() {
method onCreateOptionsMenu (line 77) | @Override
method assignImageView (line 90) | private void assignImageView(final ImageView iv, final BitmapDrawable ...
method getFile (line 99) | private void getFile(final ImageView iv, String url, final String file...
method getChartFile (line 117) | private void getChartFile() {
method randomFile (line 151) | private String randomFile() {
method refresh (line 155) | private void refresh() {
FILE: AndroidAsyncSample/src/com/koushikdutta/async/sample/middleware/BasicAuthMiddleware.java
class BasicAuthMiddleware (line 14) | public class BasicAuthMiddleware extends SimpleMiddleware {
method add (line 16) | public static BasicAuthMiddleware add(AsyncHttpClient client) {
method onRequest (line 22) | @Override
method setAuthorizationForHost (line 32) | public void setAuthorizationForHost(String host, String username, Stri...
FILE: AndroidAsyncSample/src/com/koushikdutta/async/sample/middleware/CacheOverrideMiddleware.java
class CacheOverrideMiddleware (line 15) | public class CacheOverrideMiddleware extends SimpleMiddleware {
method add (line 17) | public static CacheOverrideMiddleware add(AsyncHttpClient client) {
method onHeadersReceived (line 24) | @Override
method setCacheControlForHost (line 41) | public void setCacheControlForHost(String host, String cacheControl) {
Condensed preview — 244 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (838K chars).
[
{
"path": ".github/FUNDING.yml",
"chars": 639,
"preview": "# These are supported funding model platforms\n\ngithub: koush\npatreon: # Replace with a single Patreon username\nopen_coll"
},
{
"path": ".gitignore",
"chars": 91,
"preview": "bin\n.settings\nlocal.properties\ngen\n.gradle\nbuild\n.idea/\n.DS_Store\nokhttp/\nokio/\nlibs\n*.iml\n"
},
{
"path": "AndroidAsync/.classpath",
"chars": 352,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n\t<classpathentry kind=\"con\" path=\"org.eclipse.jdt.launching.JRE_CONTA"
},
{
"path": "AndroidAsync/Android.mk",
"chars": 801,
"preview": "#\n# Copyright (C) 2011 The Android Open Source Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "AndroidAsync/AndroidManifest.xml",
"chars": 287,
"preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n package=\"com.koushikdutta.async\"\n android:ve"
},
{
"path": "AndroidAsync/build.gradle",
"chars": 1529,
"preview": "apply plugin: 'com.android.library'\n\nandroid {\n sourceSets {\n main {\n manifest.srcFile 'AndroidMani"
},
{
"path": "AndroidAsync/lint.xml",
"chars": 53,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<lint>\n</lint>"
},
{
"path": "AndroidAsync/maven.gradle",
"chars": 4328,
"preview": "// Setup\n\n// 0) Setup your sonatype credentials by editing/creating ~/.gradle/gradle.properties and enter:\n// signing.ke"
},
{
"path": "AndroidAsync/proguard-project.txt",
"chars": 873,
"preview": "# To enable ProGuard in your project, edit project.properties\n# to define the proguard.config property as described in t"
},
{
"path": "AndroidAsync/project.properties",
"chars": 586,
"preview": "# This file is automatically generated by Android Tools.\n# Do not modify this file -- YOUR CHANGES WILL BE ERASED!\n#\n# T"
},
{
"path": "AndroidAsync/res/.gitignore",
"chars": 0,
"preview": ""
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncDatagramSocket.java",
"chars": 2092,
"preview": "package com.koushikdutta.async;\n\nimport java.io.IOException;\nimport java.net.InetSocketAddress;\nimport java.nio.ByteBuff"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncNetworkSocket.java",
"chars": 9213,
"preview": "package com.koushikdutta.async;\n\nimport android.util.Log;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimp"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncSSLException.java",
"chars": 400,
"preview": "package com.koushikdutta.async;\n\npublic class AsyncSSLException extends Exception {\n public AsyncSSLException(Throwab"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncSSLServerSocket.java",
"chars": 240,
"preview": "package com.koushikdutta.async;\n\nimport java.security.PrivateKey;\nimport java.security.cert.Certificate;\n\npublic interfa"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocket.java",
"chars": 255,
"preview": "package com.koushikdutta.async;\n\nimport java.security.cert.X509Certificate;\n\nimport javax.net.ssl.SSLEngine;\n\npublic int"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncSSLSocketWrapper.java",
"chars": 30683,
"preview": "package com.koushikdutta.async;\n\nimport android.content.Context;\nimport android.os.Build;\nimport android.util.Base64;\nim"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncSemaphore.java",
"chars": 2644,
"preview": "package com.koushikdutta.async;\n\nimport java.util.concurrent.Semaphore;\nimport java.util.concurrent.TimeUnit;\n\npublic cl"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncServer.java",
"chars": 34569,
"preview": "package com.koushikdutta.async;\n\nimport android.os.Build;\nimport android.os.Handler;\nimport android.os.SystemClock;\nimpo"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncServerSocket.java",
"chars": 127,
"preview": "package com.koushikdutta.async;\n\npublic interface AsyncServerSocket {\n public void stop();\n public int getLocalPor"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/AsyncSocket.java",
"chars": 133,
"preview": "package com.koushikdutta.async;\n\n\npublic interface AsyncSocket extends DataEmitter, DataSink {\n public AsyncServer ge"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/BufferedDataSink.java",
"chars": 3725,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/ByteBufferList.java",
"chars": 15337,
"preview": "package com.koushikdutta.async;\n\nimport android.annotation.TargetApi;\nimport android.os.Build;\nimport android.os.Looper;"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/ChannelWrapper.java",
"chars": 1625,
"preview": "package com.koushikdutta.async;\n\nimport java.io.IOException;\nimport java.net.InetAddress;\nimport java.nio.ByteBuffer;\nim"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/DataEmitter.java",
"chars": 511,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/DataEmitterBase.java",
"chars": 1038,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/DataEmitterReader.java",
"chars": 1256,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.DataCallback;\n\npublic class DataEmitterReader im"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/DataSink.java",
"chars": 542,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/DataTrackingEmitter.java",
"chars": 359,
"preview": "package com.koushikdutta.async;\n\n/**\n * Created by koush on 5/28/13.\n */\npublic interface DataTrackingEmitter extends Da"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/DatagramChannelWrapper.java",
"chars": 2557,
"preview": "package com.koushikdutta.async;\n\nimport java.io.IOException;\nimport java.net.InetAddress;\nimport java.net.InetSocketAddr"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/FileDataEmitter.java",
"chars": 2648,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.DataCallback;\nimport com.koushikdutta.async.util"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/FilteredDataEmitter.java",
"chars": 2619,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/FilteredDataSink.java",
"chars": 564,
"preview": "package com.koushikdutta.async;\n\npublic class FilteredDataSink extends BufferedDataSink {\n public FilteredDataSink(Da"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/HostnameResolutionException.java",
"chars": 183,
"preview": "package com.koushikdutta.async;\n\npublic class HostnameResolutionException extends Exception {\n public HostnameResolut"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/LineEmitter.java",
"chars": 1314,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.DataCallback;\n\nimport java.nio.ByteBuffer;\nimpor"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/PushParser.java",
"chars": 11277,
"preview": "package com.koushikdutta.async;\n\nimport android.util.Log;\nimport com.koushikdutta.async.callback.DataCallback;\n\nimport j"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/SelectorWrapper.java",
"chars": 2698,
"preview": "package com.koushikdutta.async;\n\nimport java.io.Closeable;\nimport java.io.IOException;\nimport java.nio.channels.Selectio"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/ServerSocketChannelWrapper.java",
"chars": 2099,
"preview": "package com.koushikdutta.async;\n\nimport java.io.IOException;\nimport java.net.InetAddress;\nimport java.nio.ByteBuffer;\nim"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/SocketChannelWrapper.java",
"chars": 2018,
"preview": "package com.koushikdutta.async;\n\nimport java.io.IOException;\nimport java.net.InetAddress;\nimport java.nio.ByteBuffer;\nim"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/TapCallback.java",
"chars": 67,
"preview": "package com.koushikdutta.async;\n\n\npublic interface TapCallback {\n}\n"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/ThreadQueue.java",
"chars": 1504,
"preview": "package com.koushikdutta.async;\n\nimport java.util.LinkedList;\nimport java.util.WeakHashMap;\nimport java.util.concurrent."
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/Util.java",
"chars": 9665,
"preview": "package com.koushikdutta.async;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/ZipDataSink.java",
"chars": 1782,
"preview": "package com.koushikdutta.async;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.IOException;\nimport java.nio.ByteB"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/CompletedCallback.java",
"chars": 278,
"preview": "package com.koushikdutta.async.callback;\n\npublic interface CompletedCallback {\n public class NullCompletedCallback im"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/ConnectCallback.java",
"chars": 193,
"preview": "package com.koushikdutta.async.callback;\n\nimport com.koushikdutta.async.AsyncSocket;\n\npublic interface ConnectCallback {"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/ContinuationCallback.java",
"chars": 232,
"preview": "package com.koushikdutta.async.callback;\n\nimport com.koushikdutta.async.future.Continuation;\n\npublic interface Continuat"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/DataCallback.java",
"chars": 439,
"preview": "package com.koushikdutta.async.callback;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async.Da"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/ListenCallback.java",
"chars": 301,
"preview": "package com.koushikdutta.async.callback;\n\nimport com.koushikdutta.async.AsyncServerSocket;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/ResultCallback.java",
"chars": 146,
"preview": "package com.koushikdutta.async.callback;\n\npublic interface ResultCallback<S, T> {\n public void onCompleted(Exception "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/SocketCreateCallback.java",
"chars": 176,
"preview": "package com.koushikdutta.async.callback;\n\nimport com.koushikdutta.async.AsyncNetworkSocket;\n\npublic interface SocketCrea"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/ValueCallback.java",
"chars": 147,
"preview": "package com.koushikdutta.async.callback;\n\n/**\n * Created by koush on 7/5/16.\n */\npublic interface ValueCallback<T> {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/ValueFunction.java",
"chars": 115,
"preview": "package com.koushikdutta.async.callback;\n\npublic interface ValueFunction<T> {\n T getValue() throws Exception;\n}\n"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/callback/WritableCallback.java",
"chars": 111,
"preview": "package com.koushikdutta.async.callback;\n\npublic interface WritableCallback {\n public void onWriteable();\n}\n"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/dns/Dns.java",
"chars": 5931,
"preview": "package com.koushikdutta.async.dns;\n\nimport com.koushikdutta.async.AsyncDatagramSocket;\nimport com.koushikdutta.async.As"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/dns/DnsResponse.java",
"chars": 5366,
"preview": "package com.koushikdutta.async.dns;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async.http.Mu"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/Cancellable.java",
"chars": 501,
"preview": "package com.koushikdutta.async.future;\n\npublic interface Cancellable {\n /**\n * Check whether this asynchronous op"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/Continuation.java",
"chars": 4620,
"preview": "package com.koushikdutta.async.future;\n\nimport com.koushikdutta.async.callback.CompletedCallback;\nimport com.koushikdutt"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/Converter.java",
"chars": 15011,
"preview": "package com.koushikdutta.async.future;\n\nimport android.text.TextUtils;\n\nimport com.koushikdutta.async.ByteBufferList;\n\ni"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/DependentCancellable.java",
"chars": 145,
"preview": "package com.koushikdutta.async.future;\n\npublic interface DependentCancellable extends Cancellable {\n boolean setParen"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/DependentFuture.java",
"chars": 120,
"preview": "package com.koushikdutta.async.future;\n\npublic interface DependentFuture<T> extends Future<T>, DependentCancellable {\n}\n"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/DoneCallback.java",
"chars": 132,
"preview": "package com.koushikdutta.async.future;\n\npublic interface DoneCallback<T> {\n void done(Exception e, T result) throws E"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/FailCallback.java",
"chars": 301,
"preview": "package com.koushikdutta.async.future;\n\npublic interface FailCallback {\n /**\n * Callback that is invoked when a f"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/FailConvertCallback.java",
"chars": 341,
"preview": "package com.koushikdutta.async.future;\n\npublic interface FailConvertCallback<T> {\n /**\n * Callback that is invoke"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/FailRecoverCallback.java",
"chars": 356,
"preview": "package com.koushikdutta.async.future;\n\npublic interface FailRecoverCallback<T> {\n /**\n * Callback that is invoke"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/Future.java",
"chars": 3054,
"preview": "package com.koushikdutta.async.future;\n\n\nimport java.util.concurrent.Executor;\n\npublic interface Future<T> extends Cance"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/FutureCallback.java",
"chars": 401,
"preview": "package com.koushikdutta.async.future;\n\n/**\n * Created by koush on 5/20/13.\n */\npublic interface FutureCallback<T> {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/FutureRunnable.java",
"chars": 150,
"preview": "package com.koushikdutta.async.future;\n\n/**\n * Created by koush on 12/22/13.\n */\npublic interface FutureRunnable<T> {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/FutureThread.java",
"chars": 1074,
"preview": "package com.koushikdutta.async.future;\n\nimport java.util.concurrent.ExecutorService;\n\n/**\n * Created by koush on 12/22/1"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/Futures.java",
"chars": 2188,
"preview": "package com.koushikdutta.async.future;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collection"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/HandlerFuture.java",
"chars": 1078,
"preview": "package com.koushikdutta.async.future;\n\nimport android.os.Handler;\nimport android.os.Looper;\n\n/**\n * Created by koush on"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/MultiFuture.java",
"chars": 1935,
"preview": "package com.koushikdutta.async.future;\n\nimport java.util.ArrayList;\n\n/**\n * Created by koush on 2/25/14.\n */\npublic clas"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/MultiTransformFuture.java",
"chars": 599,
"preview": "package com.koushikdutta.async.future;\n\npublic abstract class MultiTransformFuture<T, F> extends MultiFuture<T> implemen"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/SimpleCancellable.java",
"chars": 2081,
"preview": "package com.koushikdutta.async.future;\n\npublic class SimpleCancellable implements DependentCancellable {\n boolean com"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/SimpleFuture.java",
"chars": 12057,
"preview": "package com.koushikdutta.async.future;\n\nimport com.koushikdutta.async.AsyncSemaphore;\n\nimport java.util.concurrent.Cance"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/SuccessCallback.java",
"chars": 124,
"preview": "package com.koushikdutta.async.future;\n\npublic interface SuccessCallback<T> {\n void success(T value) throws Exception"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/ThenCallback.java",
"chars": 294,
"preview": "package com.koushikdutta.async.future;\n\npublic interface ThenCallback<T, F> {\n /**\n * Callback that is invoked wh"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/ThenFutureCallback.java",
"chars": 312,
"preview": "package com.koushikdutta.async.future;\n\npublic interface ThenFutureCallback<T, F> {\n /**\n * Callback that is invo"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/TransformFuture.java",
"chars": 710,
"preview": "package com.koushikdutta.async.future;\n\npublic abstract class TransformFuture<T, F> extends SimpleFuture<T> implements F"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/future/TypeConverter.java",
"chars": 146,
"preview": "package com.koushikdutta.async.future;\n\npublic interface TypeConverter<T, F> {\n Future<T> convert(F from, String from"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClient.java",
"chars": 28213,
"preview": "package com.koushikdutta.async.http;\n\nimport android.annotation.SuppressLint;\nimport android.net.Uri;\nimport android.os."
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpClientMiddleware.java",
"chars": 3570,
"preview": "package com.koushikdutta.async.http;\n\nimport com.koushikdutta.async.AsyncSocket;\nimport com.koushikdutta.async.DataEmitt"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpDelete.java",
"chars": 322,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\n\npublic class AsyncHttpDelete extends AsyncHttpRequest {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpGet.java",
"chars": 323,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\n\npublic class AsyncHttpGet extends AsyncHttpRequest {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpHead.java",
"chars": 352,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\n\n/**\n * Created by koush on 8/25/13.\n */\npublic class Asyn"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpPost.java",
"chars": 318,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\n\npublic class AsyncHttpPost extends AsyncHttpRequest {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpPut.java",
"chars": 314,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\n\npublic class AsyncHttpPut extends AsyncHttpRequest {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpRequest.java",
"chars": 7310,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\nimport android.util.Log;\n\nimport com.koushikdutta.async.As"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpResponse.java",
"chars": 435,
"preview": "package com.koushikdutta.async.http;\n\nimport com.koushikdutta.async.AsyncSocket;\nimport com.koushikdutta.async.DataEmitt"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncHttpResponseImpl.java",
"chars": 5289,
"preview": "package com.koushikdutta.async.http;\n\nimport com.koushikdutta.async.AsyncServer;\nimport com.koushikdutta.async.AsyncSock"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncSSLEngineConfigurator.java",
"chars": 347,
"preview": "package com.koushikdutta.async.http;\n\nimport javax.net.ssl.SSLContext;\nimport javax.net.ssl.SSLEngine;\n\npublic interface"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncSSLSocketMiddleware.java",
"chars": 6656,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\nimport android.os.Build;\nimport android.text.TextUtils;\n\ni"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/AsyncSocketMiddleware.java",
"chars": 13188,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\n\nimport com.koushikdutta.async.AsyncSocket;\nimport com.kou"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/BasicNameValuePair.java",
"chars": 5808,
"preview": "/*\n * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/BodyDecoderException.java",
"chars": 174,
"preview": "package com.koushikdutta.async.http;\n\npublic class BodyDecoderException extends Exception {\n public BodyDecoderExcept"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/ConnectionClosedException.java",
"chars": 314,
"preview": "package com.koushikdutta.async.http;\n\npublic class ConnectionClosedException extends Exception {\n public ConnectionCl"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/ConnectionFailedException.java",
"chars": 184,
"preview": "package com.koushikdutta.async.http;\n\npublic class ConnectionFailedException extends Exception {\n public ConnectionFa"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/Headers.java",
"chars": 4216,
"preview": "package com.koushikdutta.async.http;\n\n\nimport android.text.TextUtils;\n\nimport com.koushikdutta.async.util.TaggedList;\n\ni"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/HttpDate.java",
"chars": 3228,
"preview": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/HttpTransportMiddleware.java",
"chars": 5997,
"preview": "package com.koushikdutta.async.http;\n\nimport android.text.TextUtils;\n\nimport com.koushikdutta.async.AsyncSocket;\nimport "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/HttpUtil.java",
"chars": 5926,
"preview": "package com.koushikdutta.async.http;\n\nimport com.koushikdutta.async.AsyncServer;\nimport com.koushikdutta.async.DataEmitt"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/HybiParser.java",
"chars": 16632,
"preview": "//\n// HybiParser.java: draft-ietf-hybi-thewebsocketprotocol-13 parser\n//\n// Based on code from the faye project.\n// http"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/Multimap.java",
"chars": 4553,
"preview": "package com.koushikdutta.async.http;\n\nimport android.net.Uri;\nimport android.text.TextUtils;\n\nimport com.koushikdutta.as"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/NameValuePair.java",
"chars": 4182,
"preview": "/*\n * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/Protocol.java",
"chars": 3359,
"preview": "package com.koushikdutta.async.http;\n\nimport java.util.Hashtable;\nimport java.util.Locale;\n\n/**\n * Protocols that OkHttp"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/ProtocolVersion.java",
"chars": 9850,
"preview": "/*\n * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/RedirectLimitExceededException.java",
"chars": 194,
"preview": "package com.koushikdutta.async.http;\n\npublic class RedirectLimitExceededException extends Exception {\n public Redirec"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/RequestLine.java",
"chars": 1852,
"preview": "/*\n * $HeadURL: http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/module-main/src/main/java/org/apache/http/"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/SSLEngineSNIConfigurator.java",
"chars": 3147,
"preview": "package com.koushikdutta.async.http;\n\nimport android.os.Build;\n\nimport java.lang.reflect.Field;\nimport java.util.Hashtab"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/SimpleMiddleware.java",
"chars": 872,
"preview": "package com.koushikdutta.async.http;\n\nimport com.koushikdutta.async.future.Cancellable;\n\npublic class SimpleMiddleware i"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/WebSocket.java",
"chars": 859,
"preview": "package com.koushikdutta.async.http;\n\nimport com.koushikdutta.async.AsyncSocket;\n\npublic interface WebSocket extends Asy"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/WebSocketHandshakeException.java",
"chars": 188,
"preview": "package com.koushikdutta.async.http;\n\npublic class WebSocketHandshakeException extends Exception {\n public WebSocketH"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/WebSocketImpl.java",
"chars": 11238,
"preview": "package com.koushikdutta.async.http;\n\nimport android.text.TextUtils;\nimport android.util.Base64;\n\nimport com.koushikdutt"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/AsyncHttpRequestBody.java",
"chars": 571,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/ByteBufferListRequestBody.java",
"chars": 1420,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async.D"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/DocumentBody.java",
"chars": 2631,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/FileBody.java",
"chars": 1471,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/FilePart.java",
"chars": 890,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.http.BasicNameValuePair;\nimport com.koushikdutt"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/JSONArrayBody.java",
"chars": 1654,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/JSONObjectBody.java",
"chars": 1664,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/MultipartFormDataBody.java",
"chars": 8348,
"preview": "package com.koushikdutta.async.http.body;\n\nimport android.text.TextUtils;\n\nimport com.koushikdutta.async.ByteBufferList;"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/Part.java",
"chars": 2177,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataSink;\nimport com.koushikdutta.async.callbac"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/StreamBody.java",
"chars": 1623,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/StreamPart.java",
"chars": 850,
"preview": "package com.koushikdutta.async.http.body;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.List"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/StringBody.java",
"chars": 1774,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/StringPart.java",
"chars": 617,
"preview": "package com.koushikdutta.async.http.body;\n\nimport java.io.ByteArrayInputStream;\nimport java.io.IOException;\nimport java."
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/body/UrlEncodedFormBody.java",
"chars": 3341,
"preview": "package com.koushikdutta.async.http.body;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async.D"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/HeaderParser.java",
"chars": 3700,
"preview": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/Objects.java",
"chars": 1001,
"preview": "/*\n * Copyright (C) 2010 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/RawHeaders.java",
"chars": 10705,
"preview": "package com.koushikdutta.async.http.cache;\n\n/*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n *"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/RequestHeaders.java",
"chars": 9397,
"preview": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/ResponseCacheMiddleware.java",
"chars": 30078,
"preview": "package com.koushikdutta.async.http.cache;\n\nimport android.net.Uri;\nimport android.util.Base64;\n\nimport com.koushikdutta"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/ResponseHeaders.java",
"chars": 18434,
"preview": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/ResponseSource.java",
"chars": 1138,
"preview": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/cache/StrictLineReader.java",
"chars": 9422,
"preview": "/*\n * Copyright (C) 2012 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/callback/HttpConnectCallback.java",
"chars": 222,
"preview": "package com.koushikdutta.async.http.callback;\n\n\nimport com.koushikdutta.async.http.AsyncHttpResponse;\n\npublic interface "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/callback/RequestCallback.java",
"chars": 382,
"preview": "package com.koushikdutta.async.http.callback;\n\nimport com.koushikdutta.async.callback.ResultCallback;\nimport com.koushik"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/ChunkedDataException.java",
"chars": 181,
"preview": "package com.koushikdutta.async.http.filter;\n\npublic class ChunkedDataException extends Exception {\n public ChunkedDat"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/ChunkedInputFilter.java",
"chars": 4132,
"preview": "package com.koushikdutta.async.http.filter;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/ChunkedOutputFilter.java",
"chars": 946,
"preview": "package com.koushikdutta.async.http.filter;\n\nimport java.nio.ByteBuffer;\n\nimport com.koushikdutta.async.ByteBufferList;\n"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/ContentLengthFilter.java",
"chars": 1268,
"preview": "package com.koushikdutta.async.http.filter;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/DataRemainingException.java",
"chars": 209,
"preview": "package com.koushikdutta.async.http.filter;\n\npublic class DataRemainingException extends Exception {\n public DataRema"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/GZIPInputFilter.java",
"chars": 5579,
"preview": "package com.koushikdutta.async.http.filter;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/InflaterInputFilter.java",
"chars": 2272,
"preview": "package com.koushikdutta.async.http.filter;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/filter/PrematureDataEndException.java",
"chars": 191,
"preview": "package com.koushikdutta.async.http.filter;\n\npublic class PrematureDataEndException extends Exception {\n public Prema"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpRequestBodyProvider.java",
"chars": 253,
"preview": "package com.koushikdutta.async.http.server;\n\nimport com.koushikdutta.async.http.Headers;\nimport com.koushikdutta.async.h"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServer.java",
"chars": 12957,
"preview": "package com.koushikdutta.async.http.server;\n\nimport android.annotation.TargetApi;\nimport android.os.Build;\nimport androi"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerRequest.java",
"chars": 729,
"preview": "package com.koushikdutta.async.http.server;\n\nimport com.koushikdutta.async.AsyncSocket;\nimport com.koushikdutta.async.Da"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerRequestImpl.java",
"chars": 4938,
"preview": "package com.koushikdutta.async.http.server;\n\nimport com.koushikdutta.async.AsyncSocket;\nimport com.koushikdutta.async.Da"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponse.java",
"chars": 1660,
"preview": "package com.koushikdutta.async.http.server;\n\nimport com.koushikdutta.async.AsyncSocket;\nimport com.koushikdutta.async.By"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerResponseImpl.java",
"chars": 13227,
"preview": "package com.koushikdutta.async.http.server;\n\nimport android.text.TextUtils;\n\nimport com.koushikdutta.async.AsyncServer;\n"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncHttpServerRouter.java",
"chars": 15063,
"preview": "package com.koushikdutta.async.http.server;\n\nimport android.content.Context;\nimport android.content.res.AssetManager;\nim"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/AsyncProxyServer.java",
"chars": 2482,
"preview": "package com.koushikdutta.async.http.server;\n\nimport android.net.Uri;\n\nimport com.koushikdutta.async.AsyncServer;\nimport "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/BoundaryEmitter.java",
"chars": 6182,
"preview": "package com.koushikdutta.async.http.server;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/HttpServerRequestCallback.java",
"chars": 186,
"preview": "package com.koushikdutta.async.http.server;\n\n\npublic interface HttpServerRequestCallback {\n public void onRequest(Asy"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/MalformedRangeException.java",
"chars": 104,
"preview": "package com.koushikdutta.async.http.server;\n\npublic class MalformedRangeException extends Exception {\n}\n"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/MimeEncodingException.java",
"chars": 183,
"preview": "package com.koushikdutta.async.http.server;\n\npublic class MimeEncodingException extends Exception {\n public MimeEncod"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/RouteMatcher.java",
"chars": 150,
"preview": "package com.koushikdutta.async.http.server;\n\npublic interface RouteMatcher {\n AsyncHttpServerRouter.RouteMatch route("
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/StreamSkipException.java",
"chars": 179,
"preview": "package com.koushikdutta.async.http.server;\n\npublic class StreamSkipException extends Exception {\n public StreamSkipE"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/http/server/UnknownRequestBody.java",
"chars": 1875,
"preview": "package com.koushikdutta.async.http.server;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.Da"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/parser/AsyncParser.java",
"chars": 488,
"preview": "package com.koushikdutta.async.parser;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.DataSin"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/parser/ByteBufferListParser.java",
"chars": 1927,
"preview": "package com.koushikdutta.async.parser;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/parser/DocumentParser.java",
"chars": 1152,
"preview": "package com.koushikdutta.async.parser;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.DataSin"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/parser/JSONArrayParser.java",
"chars": 901,
"preview": "package com.koushikdutta.async.parser;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.DataSin"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/parser/JSONObjectParser.java",
"chars": 899,
"preview": "package com.koushikdutta.async.parser;\n\nimport com.koushikdutta.async.DataEmitter;\nimport com.koushikdutta.async.DataSin"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/parser/StringParser.java",
"chars": 1379,
"preview": "package com.koushikdutta.async.parser;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async.Data"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/stream/ByteBufferListInputStream.java",
"chars": 922,
"preview": "package com.koushikdutta.async.stream;\n\nimport com.koushikdutta.async.ByteBufferList;\n\nimport java.io.IOException;\nimpor"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/stream/FileDataSink.java",
"chars": 737,
"preview": "package com.koushikdutta.async.stream;\n\nimport com.koushikdutta.async.AsyncServer;\n\nimport java.io.File;\nimport java.io."
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/stream/InputStreamDataEmitter.java",
"chars": 3950,
"preview": "package com.koushikdutta.async.stream;\n\nimport com.koushikdutta.async.AsyncServer;\nimport com.koushikdutta.async.ByteBuf"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/stream/OutputStreamDataCallback.java",
"chars": 1341,
"preview": "package com.koushikdutta.async.stream;\n\nimport java.io.IOException;\nimport java.io.OutputStream;\nimport java.nio.ByteBuf"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/stream/OutputStreamDataSink.java",
"chars": 2785,
"preview": "package com.koushikdutta.async.stream;\n\nimport java.io.IOException;\nimport java.io.OutputStream;\nimport java.nio.ByteBuf"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/Allocator.java",
"chars": 1082,
"preview": "package com.koushikdutta.async.util;\n\nimport com.koushikdutta.async.ByteBufferList;\n\nimport java.nio.ByteBuffer;\n\n/**\n *"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/ArrayDeque.java",
"chars": 28768,
"preview": "/*\n * Written by Josh Bloch of Google Inc. and released to the public domain,\n * as explained at http://creativecommons."
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/Charsets.java",
"chars": 344,
"preview": "package com.koushikdutta.async.util;\n\nimport java.nio.charset.Charset;\n\n/** From java.nio.charset.Charsets */\npublic cla"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/Deque.java",
"chars": 22180,
"preview": "/*\n * Written by Doug Lea and Josh Bloch with assistance from members of\n * JCP JSR-166 Expert Group and released to the"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/FileCache.java",
"chars": 8544,
"preview": "package com.koushikdutta.async.util;\n\nimport java.io.File;\nimport java.io.FileInputStream;\nimport java.io.IOException;\ni"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/FileUtility.java",
"chars": 642,
"preview": "package com.koushikdutta.async.util;\n\nimport java.io.File;\n\n/**\n * Created by koush on 4/7/14.\n */\npublic class FileUtil"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/HashList.java",
"chars": 2013,
"preview": "package com.koushikdutta.async.util;\n\nimport java.util.ArrayList;\nimport java.util.Hashtable;\nimport java.util.Set;\n\n/**"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/IdleTimeout.java",
"chars": 932,
"preview": "package com.koushikdutta.async.util;\n\nimport android.os.Handler;\n\nimport com.koushikdutta.async.AsyncServer;\n\npublic cla"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/LruCache.java",
"chars": 10533,
"preview": "/*\n * Copyright (C) 2011 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/StreamUtility.java",
"chars": 4014,
"preview": "package com.koushikdutta.async.util;\n\nimport java.io.ByteArrayOutputStream;\nimport java.io.Closeable;\nimport java.io.Dat"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/TaggedList.java",
"chars": 402,
"preview": "package com.koushikdutta.async.util;\n\nimport java.util.ArrayList;\n\npublic class TaggedList<T> extends ArrayList<T> {\n "
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/ThrottleTimeout.java",
"chars": 2354,
"preview": "package com.koushikdutta.async.util;\n\nimport android.os.Handler;\n\nimport com.koushikdutta.async.AsyncServer;\nimport com."
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/TimeoutBase.java",
"chars": 1853,
"preview": "package com.koushikdutta.async.util;\n\nimport android.os.Handler;\n\nimport com.koushikdutta.async.AsyncServer;\nimport com."
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/util/UntypedHashtable.java",
"chars": 570,
"preview": "package com.koushikdutta.async.util;\n\nimport java.util.Hashtable;\n\npublic class UntypedHashtable {\n private Hashtable"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/wrapper/AsyncSocketWrapper.java",
"chars": 201,
"preview": "package com.koushikdutta.async.wrapper;\n\nimport com.koushikdutta.async.AsyncSocket;\n\npublic interface AsyncSocketWrapper"
},
{
"path": "AndroidAsync/src/com/koushikdutta/async/wrapper/DataEmitterWrapper.java",
"chars": 186,
"preview": "package com.koushikdutta.async.wrapper;\n\nimport com.koushikdutta.async.DataEmitter;\n\npublic interface DataEmitterWrapper"
},
{
"path": "AndroidAsync/test/assets/hello.txt",
"chars": 11,
"preview": "hello world"
},
{
"path": "AndroidAsync/test/assets/test.json",
"chars": 18,
"preview": "{\n \"foo\": \"bar\"\n}"
},
{
"path": "AndroidAsync/test/res/values/strings.xml",
"chars": 123,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n <string name=\"app_name\">AndroidAsyncTestTest</string>\n\n</resourc"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/BodyTests.java",
"chars": 577,
"preview": "package com.koushikdutta.async.test;\n\nimport androidx.test.runner.AndroidJUnit4;\n\nimport com.koushikdutta.async.http.Mul"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/ByteUtilTests.java",
"chars": 2849,
"preview": "package com.koushikdutta.async.test;\n\nimport com.koushikdutta.async.ByteBufferList;\nimport com.koushikdutta.async.Filter"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/CacheTests.java",
"chars": 5251,
"preview": "package com.koushikdutta.async.test;\n\nimport android.content.res.AssetManager;\nimport androidx.test.InstrumentationRegis"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/CallbackTests.java",
"chars": 3556,
"preview": "package com.koushikdutta.async.test;\n\nimport androidx.test.runner.AndroidJUnit4;\n\nimport com.koushikdutta.async.AsyncSer"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/ConscryptTests.java",
"chars": 7650,
"preview": "/*\n * Copyright 2013 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/ConvertTests.java",
"chars": 642,
"preview": "package com.koushikdutta.async.test;\n\nimport androidx.test.runner.AndroidJUnit4;\n\nimport com.koushikdutta.async.future.S"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/DnsTests.java",
"chars": 3462,
"preview": "package com.koushikdutta.async.test;\n\nimport com.koushikdutta.async.AsyncDatagramSocket;\nimport com.koushikdutta.async.A"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/FileCacheTests.java",
"chars": 7042,
"preview": "package com.koushikdutta.async.test;\n\nimport androidx.test.runner.AndroidJUnit4;\n\nimport com.koushikdutta.async.util.Fil"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/FileTests.java",
"chars": 1609,
"preview": "package com.koushikdutta.async.test;\n\n\nimport androidx.test.runner.AndroidJUnit4;\n\nimport com.koushikdutta.async.AsyncSe"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/FutureTests.java",
"chars": 16021,
"preview": "package com.koushikdutta.async.test;\n\nimport android.os.Handler;\nimport android.os.Looper;\nimport androidx.test.runner.A"
},
{
"path": "AndroidAsync/test/src/com/koushikdutta/async/test/HttpClientTests.java",
"chars": 14767,
"preview": "package com.koushikdutta.async.test;\n\nimport android.net.Uri;\nimport androidx.test.runner.AndroidJUnit4;\nimport android."
}
]
// ... and 44 more files (download for full content)
About this extraction
This page contains the full source code of the koush/AndroidAsync GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 244 files (769.9 KB), approximately 174.0k tokens, and a symbol index with 2099 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.