# chuck **Repository Path**: HarmonyOS-tpc/chuck ## Basic Information - **Project Name**: chuck - **Description**: chuck is a simple in-app HTTP inspector for OkHttp clients. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 2 - **Created**: 2021-04-01 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-network **Tags**: None ## README ## chuck chuck is a simple in-app HTTP inspector for OkHttp clients. chuck intercepts and persists all HTTP requests and responses inside your application, and provides a UI for inspecting their content. ## chuck includes: Intercepts HTTP network calls of the application. Store intercepted calls in database. Displaying of intercepted data in library UI. Supports deleting of retained data. Displays notification when library is recording network calls. ## Usage Instructions 1) Add chuck Interceptor to Builder() method of OkHttpClient 2) Pass the openharmony context to the chuckIntercepter constructor in the addInterceptor() method of OkHttpClient 3) Use above OkHttpClient in application methods whenever requesting any network call. OkHttpClient getClient(Context context) { return new OkHttpClient.Builder() .addInterceptor(new ChuckInterceptor(context)) .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)) Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://httpbin.org") .addConverterFactory(GsonConverterFactory.create()) .client(getClient()) .build(); return retrofit.create(HttpbinApi.class); .build(); } ## Installation tutorial 1.For using chuck module in sample app,include the below library dependency in build.gradel: dependencies { implementation project(path: ':library') implementation "com.squareup.okhttp3:logging-interceptor:3.12.10" implementation "com.squareup.retrofit2:retrofit:2.6.4" implementation "com.squareup.retrofit2:converter-gson:2.6.4" } 2. Using the library.har, make sure to add library.har file in the entry/libs folder along with the other library dependencies. Modify the dependencies in the entry/build.gradle file. dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) implementation "com.squareup.okhttp3:logging-interceptor:3.12.10" implementation "com.squareup.retrofit2:retrofit:2.6.4" implementation "com.squareup.retrofit2:converter-gson:2.6.4" } 3. For using chuck from a remote repository in separate application, add the below dependencies in "entry" build.gradle. Modify entry build.gradle as below : dependencies { implementation 'io.openharmony.tpc.thirdlib:chuck:1.0.0' implementation "com.squareup.okhttp3:logging-interceptor:3.12.10" implementation "com.squareup.retrofit2:retrofit:2.6.4" implementation "com.squareup.retrofit2:converter-gson:2.6.4" } Note: example baseUrl can be "https://httpbin.org" chuck library Should start intercepting and recording http request/response of the application and show ongoing process in a notification. ## Version Iteration v1.0.0-ohos ## License Copyright (C) 2017 Jeff Gilfelt. 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.