본문 바로가기

안드로이드 스튜디오

[안드로이드 스튜디오] OkHttp 로그 해석

728x90
반응형

 

 

 

 

 

 

1. 요청하고 싶은 주소로 GET/ END GET

 

2022-09-13 10:55:43.333 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: --> GET https://reqres.in/api/unknown

 

-> 주소로 GET요청을 보냄

 

2022-09-13 10:55:43.333 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: --> END GET

 

 

-> GET 요청이 끝남


 

2. 서버에서 응답을 받음, 그에 대한 정보


2022-09-13 10:55:44.335 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: <-- 200 https://reqres.in/api/unknown (1000ms)

 

-> 서버 응답(200), 응답 속도


2022-09-13 10:55:44.335 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: date: Tue, 13 Sep 2022 01:55:44 GMT

 

-> 응답 요청 시간 (받은 시간)


2022-09-13 10:55:44.335 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: content-type: application/json; charset=utf-8

 

-> 응답 방법 (Type = json)


 

3. 요청한 서버에 대한 정보(서버 정보)

 

2022-09-13 10:55:44.336 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=qdsxMrU3MF5ZjVEEWQTd1WCM9lWjLJ3ozfbmuRU%2FlwYNV1v7vnIH1sXjkVG1SFmYZQuRZTdBzT1jUGXKoYsuRZxwRaAFihx%2BwF%2BgCgIqJSSoNOgRNd6TAwHxErUmvfLf1FNYttmN%2FA%3D%3D"}],"group":"cf-nel","max_age":604800}

 

-> 테스트 서버의 report


2022-09-13 10:55:44.336 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
2022-09-13 10:55:44.336 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: vary: Accept-Encoding
2022-09-13 10:55:44.336 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: server: cloudflare
2022-09-13 10:55:44.336 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: cf-ray: 749d432bea1ee031-NRT

 


4. 서버에서 응답을 받음, 그에 대한 정보


2022-09-13 10:55:44.340 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: {"page":1,"per_page":6,"total":12,"total_pages":2,"data":[{"id":1,"name":"cerulean","year":2000,"color":"#98B2D1","pantone_value":"15-4020"},{"id":2,"name":"fuchsia rose","year":2001,"color":"#C74375","pantone_value":"17-2031"},{"id":3,"name":"true red","year":2002,"color":"#BF1932","pantone_value":"19-1664"},{"id":4,"name":"aqua sky","year":2003,"color":"#7BC4C4","pantone_value":"14-4811"},{"id":5,"name":"tigerlily","year":2004,"color":"#E2583E","pantone_value":"17-1456"},{"id":6,"name":"blue turquoise","year":2005,"color":"#53B0AE","pantone_value":"15-5217"}],"support":{"url":"https://reqres.in/#support-heading","text":"To keep ReqRes free, contributions towards server costs are appreciated!"}}

 

-> 요청한 객체에 있는 key-value 


2022-09-13 10:55:44.340 25546-25679/com.example.javaretrokhttptest I/okhttp.OkHttpClient: <-- END HTTP (705-byte body)
2022-09-13 10:55:44.349 25546-25546/com.example.javaretrokhttptest D/TAG: 200

 

-> onResponse에 넣은 Log 코드에 대한 응답(응답 코드 200)

Log.d("TAG",response.code()+"");

 

 

 

 

 

5. 화면에 결과 출력

resource.page + " Page\n" + resource.total + " Total\n" + resource.totalPages + " Total Pages\n";
728x90
반응형