com.wecanstudio.xdsjs.save.Model.net.LoggingInterceptor.java Source code

Java tutorial

Introduction

Here is the source code for com.wecanstudio.xdsjs.save.Model.net.LoggingInterceptor.java

Source

/*
 * Mr.Mantou - On the importance of taste
 * Copyright (C) 2015  XiNGRZ <xxx@oxo.ooo>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.wecanstudio.xdsjs.save.Model.net;

import android.util.Log;

import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import java.io.IOException;

public class LoggingInterceptor implements Interceptor {
    private static final String TAG = "OkHttp";

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Log.e(TAG, String.format("%s\n%s", request, request.headers()));
        Response response = chain.proceed(request);
        Log.e(TAG, String.format("%s\n%s", response, response.headers()));
        return response;
    }
}