package Ġcom . sc ur ab . k up ro xy . ext Ċ Ċ import Ġcom . sc ur ab . k up ro xy . comm . I Request Ċ import Ġcom . sc ur ab . k up ro xy . comm . I Response Ċ import Ġcom . sc ur ab . k up ro xy . comm . Request Ċ import Ġcom . sc ur ab . k up ro xy . comm . Url Ċ import Ġio . ktor . application . Application Call Ċ import Ġio . ktor . client . request . headers Ċ import Ġio . ktor . client . request . request Ċ import Ġio . ktor . http . HttpStatusCode Ċ import Ġio . ktor . request . header Ċ import Ġio . ktor . request . http Method Ċ import Ġio . ktor . request . uri Ċ import Ġio . ktor . response . respond Ċ Ċ fun ĠApplication Call . to Domain Request (): ĠI Request Ġ{ ĊĠĠĠ Ġval Ġhost Header Ġ= Ġrequest . header (" host ") ĊĠĠĠ Ġval Ġurl Ġ= Ġrequest . uri ĊĠĠĠĠĠĠĠ Ġ. take If Ġ{ Ġit . startsWith (" http ") Ġ} ĊĠĠĠĠĠĠĠ Ġ?: Ġ" https ://${ host Header }${ request . uri }" ĊĊĠĠĠ Ġreturn ĠRequest ( ĊĠĠĠĠĠĠĠ ĠUrl ( url ), ĊĠĠĠĠĠĠĠ Ġrequest . http Method . value , ĊĠĠĠĠĠĠĠ Ġheaders Ġ= Ġrequest . headers . to Domain Headers () ĊĠĠĠ Ġ) Ċ } Ċ Ċ suspend Ġfun ĠApplication Call . respond ( domain Response : ĠI Response , Ġblock : ĠApplication Call . () Ġ-> ĠUnit Ġ= Ġ{}) Ġ{ ĊĠĠĠ Ġval Ġreal Response Ġ= Ġthis . response ĊĠĠĠ Ġreal Response . status ( HttpStatusCode . from Value ( domain Response . status )) ĊĠĠĠ Ġdomain Response . headers . forEach Ġ{ Ġ( header Name , Ġheader Value ) Ġ-> ĊĠĠĠĠĠĠĠ Ġreal Response . headers . append ( header Name , Ġheader Value , Ġsafe Only Ġ= Ġfalse ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġapply ( block ) ĊĠĠĠ Ġthis . respond ( domain Response . body ) Ċ } Ċ