Gander is a simple in-app HTTP inspector for Android OkHttp clients. Gander intercepts and persists all HTTP requests and responses inside your application, and provides a UI for inspecting their content.
Gander is a simple in-app HTTP inspector for Android OkHttp clients. Gander intercepts and persists all HTTP requests and responses inside your application, and provides a UI for inspecting their content.
get sample apk from Google Play Store
Gander requires Android 4.1+ and OkHttp 3.x.
Warning: The data generated and stored when using this interceptor may contain sensitive information such as Authorization or Cookie headers, and the contents of request and response bodies. It is intended for use during development, and not in release builds or other production deployments.
Based on your IDE you can import library in one of the following ways
Add the dependency in your build.gradle
file. Add it alongside the no-op
variant to isolate Gander from release builds as follows:
// if persistence is needed (Uses Room to store the calls in DB)
debugImplementation 'com.ashokvarma.android:gander-persistence:3.1.0'
// if persistence is not needed (Data retained in memory lost on app close)
debugImplementation 'com.ashokvarma.android:gander-imdb:3.1.0'
releaseImplementation 'com.ashokvarma.android:gander-no-op:3.1.0'
If you want this in library in both release and debug builds, then try this :
// if persistence is needed (Uses Room to store the calls in DB)
implementation 'com.ashokvarma.android:gander-persistence:3.1.0'
// if persistence is not needed (Data retained in memory lost on app close)
implementation 'com.ashokvarma.android:gander-imdb:3.1.0'
<!--if persistence is needed (Uses Room to store the calls in DB)-->
<dependency>
<groupId>com.ashokvarma.android</groupId>
<artifactId>gander-persistence</artifactId>
<version>3.1.0</version>
<type>pom</type>
</dependency>
<!--if persistence is not needed (Data lost once app is dead)-->
<dependency>
<groupId>com.ashokvarma.android</groupId>
<artifactId>gander-imdb</artifactId>
<version>3.1.0</version>
<type>pom</type>
</dependency>
or Download the latest Gander Persistence JAR / IMDB JAR
@Override
public void onCreate() {
super.onCreate();
// For Persistence (Uses Room to store the calls in DB)
Gander.setGanderStorage(GanderPersistence.getInstance(this));
// For In Memory DB (Data retained in memory lost on app close)
Gander.setGanderStorage(GanderIMDB.getInstance());
}
Create an instance of GanderInterceptor
and add it as an interceptor when building your OkHttp client:
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(new GanderInterceptor(context))
.build();
That’s it! Gander will now record all HTTP interactions made by this OkHttp client.
Sticky => true and Normal => false
new GanderInterceptor(context).showNotification(true/false)
Launch the Gander UI directly within your app with the intent from Gander.getLaunchIntent()
.
startActivity(Gander.getLaunchIntent(this));
Gander.addAppShortcut(this);
You can redact headers that may contain sensitive information by calling redactHeader()
.
new GanderInterceptor(context)
.redactHeader("Authorization")
.redactHeader("Cookie");
Set Response Max length to store
new GanderInterceptor(context).maxContentLength(10240L)//the maximum length (in bytes)
Set the retention period for HTTP transaction data captured
new GanderInterceptor(context).retainDataFor(Period.ONE_WEEK)
You can chain all the method calls and pass it to OkHttp
new OkHttpClient.Builder()
.addInterceptor(new GanderInterceptor(context)
.showNotification(false)
.maxContentLength(250000L)
.retainDataFor(GanderInterceptor.Period.FOREVER)
.redactHeader("Authorization"))
Please refer to this section of the OkHttp wiki. You can choose to use Gander as either an application or network interceptor, depending on your requirements.
Support it by joining stargazers for this repository. ⭐
Chuck (parent repo)
Awesome Icon Designer
Gander uses the following open source libraries:
Copyright (C) 2018 Ashok Varma.
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.