๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋นˆ ๊ตฌ๋ฉ ์ฑ„์šฐ๊ธฐ

[Android][Retrofit] HTML Response

์ด์ œ๊ป ์›น๋ทฐ์—์„œ url์„ ๋กœ๋“œํ•˜๋ฉด ๋‹น์—ฐํžˆ 200์ด ๋–จ์–ด์ง€๋‹ˆ๊นŒ html ํŒŒ์ผ์ด ํ™”๋ฉด์— ๋…ธ์ถœ๋˜๋Š” ์‹œ๋‚˜๋ฆฌ์˜ค๋งŒ ์ž‘์—…ํ•˜๋‹ค๊ฐ€, 

์ด๋ฒˆ์—๋Š” api๋ฅผ ์ฐ”๋Ÿฌ์„œ 200 ์ฝ”๋“œ๋ฅผ ๋ฐ›์•„์•ผ์ง€๋งŒ ์›น๋ทฐ๋ฅผ ๋…ธ์ถœ์‹œ์ผœ html ํŒŒ์ผ์„ ๋กœ๋“œํ•˜๋Š” ์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ์ž‘์—…ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

 

๊ธฐ์กด ์•ฑ์—์„œ ์‚ฌ์šฉํ•ด ์˜จ Retrofit2๋กœ ์ž‘์—…ํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค. 

 

๊ณ ๋ฏผํ•œ ์‚ฌํ•ญ๋“ค์ด๋‹ค.

 

1. Call ๋˜๋Š” Response ๋‘˜ ์ค‘์— ์–ด๋Š ๊ฒƒ์„ ์“ธ ๊ฒƒ์ธ๊ฐ€?  >  Response

Coroutine์„ ์“ฐ๊ณ  ์žˆ์–ด์„œ, Response๊ฐ€ ๋” ์ ํ•ฉํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค. ๋น„๋™๊ธฐ ์ž‘์—…์— Response๊ฐ€ Call๋ณด๋‹ค ์‚ฌ์šฉํ•˜๊ธฐ ์ข‹๋‹ค๊ณ  ํ•œ๋‹ค. 

 

https://jeongupark-study-house.tistory.com/208

 

Retrofit call ๊ณผ Response ์ฐจ์ด

Android ๊ฐœ๋ฐœ ์‹œ ๋„คํŠธ์›Œํฌ ์ž‘์—…ํ•  ๋•Œ ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ด๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋‹ˆ๋Š” Retrofit ์ž…๋‹ˆ๋‹ค. (Retrofit์˜ ์ƒ์„ธ ๋‚ด์šฉ์€ https://square.github.io/retrofit/ ์—ฌ๊ธฐ์„œ ํ™•์ธํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค) ์—ฌ๊ธฐ์„œ ์•Œ์•„๋ณผ ๋‚ด์šฉ์€ Retrofit์„..

jeongupark-study-house.tistory.com

https://stackoverflow.com/questions/64124670/call-or-response-in-retrofit

 

Call or Response in Retrofit?

I want to know the difference between Call And Response ? That when to use Call & when to use to Response in Retrofit ? @GET("/albums/{id}") suspend fun functionOne(@Path(value = &quo...

stackoverflow.com

 

 

2. Html reponse๋ฅผ ๋ฐ›๊ธฐ ์œ„ํ•ด ์–ด๋–ค ๊ฐ์ฒด๋ฅผ ์จ์•ผ ํ•˜๋Š”๊ฐ€?  >  ResponseBody

์˜ˆ์ œ๋กœ html response๋Š” ResponseBody๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ๋“ค๋งŒ ํ™•์ธํ–ˆ๋‹ค.

 

https://jaejong.tistory.com/34

 

[์•ˆ๋“œ๋กœ์ด๋“œ] Retrofit2 - ResponseBody ๋ฐ˜ํ™˜ํƒ€์ž… ์ถœ๋ ฅ

Retrofit - ResponseBody ์›์‹œ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ Call - Retrofit์œผ๋กœ ๋ฐ›์•„์˜จ ์›์‹œ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€๊ณต์—†์ด ์ถœ๋ ฅํ•˜๊ธฐ Open API '๊ณต๊ณต๋ฐ์ดํ„ฐ ํฌํ„ธ' ์ธก์ •์†Œ์ •๋ณด ์กฐํšŒ ์„œ๋น„์Šค API - 'TM ๊ธฐ์ค€์ขŒํ‘œ ์กฐํšŒ' ์‘๋‹ต๊ฒฐ๊ณผ๋ฅผ JSON / XML ๊ฐ..

jaejong.tistory.com

 

https://mobikul.com/handle-html-response-from-http-request-using-retrofit/

 

Handle the HTML Response from HTTP Request using Retrofit - Mobikul

In this blog, we will learn how to handle the HTML Keep Reading...

mobikul.com

https://square.github.io/okhttp/4.x/okhttp/okhttp3/-response-body/

 

ResponseBody - OkHttp - OkHttp

//okhttp/okhttp3/ResponseBody ResponseBody [common]\ expect abstract class ResponseBody : Closeable A one-shot stream from the origin server to the client application with the raw bytes of the response body. Each response body is supported by an active con

square.github.io

 

* ResponseBody๋ฅผ ๋ฐ›์„ ๊ฒฝ์šฐ ๊ผญ close ํ•ด์•ผ ํ•œ๋‹ค. ์•ˆ๊ทธ๋Ÿฌ๋ฉด ๋ฆฌ์†Œ์Šค ๋ˆ„์ˆ˜๋กœ ์•ฑ์ด ๋Š๋ ค์ง€๊ฑฐ๋‚˜ ํฌ๋ž˜์‹œ๋‚œ๋‹ค๊ณ  ํ•œ๋‹ค.

 

 

3. html response๋ฅผ ์›น๋ทฐ์— ๋กœ๋“œํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ• > WebView.loadData(ResposeBody.string(), "text/html",  "utf-8")

WebView์— loadData() ๋ผ๋Š” ํ•จ์ˆ˜๋ฅผ ์“ฐ๋ฉด ๋˜๋Š” ๊ฑฐ์˜€๋‹ค.

html ํŒŒ์ผ์˜ ํ…์ŠคํŠธ ๊ฐ’์„ Response.body().string()์œผ๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. (Response.body()๊ฐ€ ResponseBody ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.)

Response.body().string์ด ResponseBody๋ฅผ close()ํ•ด์ฃผ๊ธฐ๋„ ํ•˜๋‹ˆ, 

 

https://stackoverflow.com/questions/13816464/how-to-load-html-string-in-a-webview

 

How to load html string in a webview?

i have a html string containing this: <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> <html> <head> <meta http-equiv="content-type" conte...

stackoverflow.com

 

https://developer.android.com/reference/android/webkit/WebView#loadData(java.lang.String,%20java.lang.String,%20java.lang.String)
 

WebView  |  Android Developers

android.net.wifi.hotspot2.omadm

developer.android.com


ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜๋Š”๋ฐ, html response๋ฅผ webview์— ๋กœ๋“œํ•˜๋Š” ๋ฐ์— ์‹คํŒจํ–ˆ๋‹ค. html ๋‚ด์šฉ์„ ๊นŒ์„œ ๋ดค๋”๋‹ˆ, ์ด๋ฏธ์ง€๋ฅผ ์„œ๋ฒ„์—์„œ ๋ฐ›์•„ ๋กœ๋“œํ•˜๋Š” ๊ฑฐ์˜€๋‹ค. html reponse๋ฅผ text๋กœ ๋ฐ›์•„์„œ webview์— ๋„์›Œ์ฃผ๋ฉด, ์ด๋ฏธ์ง€ ํŒŒ์ผ ์ฃผ์†Œ๋ฅผ ๋กœ์ปฌ์—์„œ ์ฐพ์œผ๋ ค๊ณ  ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋กœ๋“œ ์‹คํŒจ๊ฐ€ ๋‚˜์˜ค๋Š” ๊ฒƒ์„ ์•Œ์•˜๋‹ค.


invisible ์ƒํƒœ์˜ ์›น๋ทฐ์—์„œ url์„ ๋กœ๋“œํ•˜๊ณ  200 ์ƒํƒœ ์ฝ”๋“œ๊ฐ€ ๋–จ์–ด์ง€๋ฉด ์›น๋ทฐ๋ฅผ visible ํ•˜๊ฒŒ ๋งŒ๋“ค๋„๋ก ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ์•˜๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์•ˆ๋“œ๋กœ์ด๋ธŒ ์›น๋ทฐ๋Š” 200 ์ƒํƒœ ์ฝ”๋“œ๋ฅผ ๋ฐ›๋Š” ๊ธฐ๋Šฅ์€ ์—†์—ˆ๋‹ค. ๊ทธ๋‚˜๋งˆ ์—๋Ÿฌ์ฝ”๋“œ๋Š” ๋ฐ›์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

https://zerodice0.tistory.com/207

 

Android์˜ WebView๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ, ํด๋ผ์ด์–ธํŠธ ์—๋Ÿฌ๋ฅผ ์ถ”์ ํ•˜๋Š” ๋ฐฉ๋ฒ• ์ •๋ฆฌ.

WevView๋ฅผ ์„ธํŒ…ํ•ด๋ณด์ž. ์šฐ์„ ์€ ๋ ˆ์ด์•„์›ƒ์„ ๋งŒ๋“ค์–ด๋ณด์ž. ์›น๋ทฐ๋ฅผ ์•กํ‹ฐ๋น„ํ‹ฐ ํ•œ ๊ฐ€๋“ ๋„์›Œ๋†“์„๊ฑฐ๋‹ˆ๊นŒ, ์•„๋ž˜์ฒ˜๋Ÿผ xml ํŒŒ์ผ์„ ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค. <?xml version="1.0" encoding="utf-8"?> xmlํŒŒ์ผ์˜ ์ž‘์„ฑ์ด ๋๋‚ฌ๋‹ค๋ฉด, ์ด

zerodice0.tistory.com

 

๊ทธ๋Ÿฐ๋ฐ ์—ฐ๊ฒฐ ์ƒํƒœ๊ฐ€ 200์œผ๋กœ ๋–จ์–ด์ ธ๋„, ํ™”๋ฉด์„ ๋กœ๋“œํ•˜๋ฉด์„œ ๋‹ค๋ฅธ ๋ฆฌ์†Œ์Šค์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๋ฉด ์—๋Ÿฌ์ฝ”๋“œ๋ฅผ ๋ฐ›๊ฒŒ ๋˜์–ด ์—ฐ๊ฒฐ ์ƒํƒœ๋งŒ์˜ 200 ์ƒํƒœ๋ฅผ ์•Œ๊ธฐ ์–ด๋ ค์› ๋‹ค.

๋ถ„๋ช… 200์œผ๋กœ ๋–จ์–ด์ ธ์•ผ ๋งˆ๋•…ํ•œ๋ฐ, ์–ด๋””์„œ ์ž˜๋ชป๋๋Š”์ง€ ํŒŒ์•…ํ•˜๊ธฐ ์œ„ํ•ด์„œ ํฌ๋กฌ ๊ฐœ๋ฐœ์ž ๋„๊ตฌ๋ฅผ ํ™œ์šฉํ–ˆ๋‹ค.

 

https://velog.io/@pixelstudio/%ED%81%AC%EB%A1%AC-%EA%B0%9C%EB%B0%9C%EC%9E%90-%EB%8F%84%EA%B5%AC%EB%A1%9C-%EB%B3%B4%EB%8A%94-HTTP-%ED%97%A4%EB%8D%94-%EC%95%8C%EC%95%84%EB%B3%B4%EA%B8%B0

 

ํฌ๋กฌ ๊ฐœ๋ฐœ์ž ๋„๊ตฌ๋กœ ๋ณด๋Š” HTTP ํ—ค๋” ์•Œ์•„๋ณด๊ธฐ

๋ถ€๋„๋Ÿฝ์ง€๋งŒ ๋‚œ ์ด๊ฑฐ ๋ชฐ๋ž์—ˆ๋‹ค... ๋‚ด๊ฐ€ ์™œ ํ•ญ์ƒ ํƒˆ๋ฝํ•˜๋Š”์ง€ ์ด์œ ๋Š” ์•Œ๊ณ ์žˆ์œผ๋‚˜ ํ•ญ์ƒ ์‹ค์ฒœ์ด ๋ฌธ์ œ์˜€๋‹ค. ์šฐ์„  ์ œ๋Œ€๋กœ ํ•™์Šตํ•˜์ง€ ๋ชปํ•ด ๊ธฐ์ดˆ ์ˆ˜์ค€์ด ๋ฏธ๋‹ฌ์ด๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. + ์งˆ๋ฌธ์˜ ์˜๋„ ํŒŒ์•…๋ชปํ•จ. ์˜๋„

velog.io

 

 

์š” ๋ฌธ์ œ์˜ ์—๋Ÿฌ์ฝ”๋“œ

favicon.ico๊ฐ€ ๋ฌด์—‡์ธ์ง€ ์ฐพ์•„๋ณด์•˜๊ณ ..

https://cheonfamily.tistory.com/7

 

favicon.ico ์˜ค๋ฅ˜ 404 ๋ฉ”์‹œ์ง€ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

์›นํŽ˜์ด์ง€ ๊ฐœ๋ฐœ์„ ํ•˜๋‹ค๋ณด๋ฉด ๊ฐœ๋ฐœ์ž๋„๊ตฌ F12 ์˜ ์ฝ˜์†”์ฐฝ์— favicon.ico error message ๊ฐ€ ๋ณด์ž…๋‹ˆ๋‹ค. ๋ญ ๋ฌธ์ œ๋˜๋Š” ๊ฑด ์—†์ง€๋งŒ, ๋นจ๊ฐ„์ƒ‰์œผ๋กœ ํŒ ๋œจ๋‹ˆ๊นŒ ์„ฑ๊ฐ€์‹œ์ฃ ... ์ด favicon.ico ๋Š” ๋ธŒ๋ผ์šฐ์ € ํƒ€์ดํ‹€ ๋งจ ์™ผ์ชฝ์— ๋ณด

cheonfamily.tistory.com

 

์„œ๋ฒ„ ๊ฐœ๋ฐœ์ž๋ถ„๊ป˜ ํ™•์ธ ์š”์ฒญ๋“œ๋ ค์„œ ๊ทธ ๋‹ค์Œ๋ถ€ํ„ฐ๋Š” 200์œผ๋กœ ๋ฐ›์•˜๋‹ค.

 


์ด๋ ‡๊ฒŒ ์‹ค์ปท ํ—ค๋ฉ”๊ณ  ์‚ฝ์งˆํ–ˆ๋Š”๋ฐ ๊ฒฐ๊ตญ์—” ๋‹ค๋ฅธ ๋ฐฉ์‹์œผ๋กœ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ–ˆ๋‹ค. ๐Ÿ˜‚ ๊ทธ๋ž˜ ๋ฐฐ์šด ๊ฒŒ ๊ฝค ์žˆ์œผ๋‹ˆ ๊ดœ์ฐฎ๋‹ค.