@@ -36,6 +36,8 @@ import java.io.BufferedInputStream
3636import java.io.BufferedReader
3737import java.io.InputStreamReader
3838import java.io.PrintWriter
39+ import java.net.HttpURLConnection
40+ import java.net.Proxy
3941import java.net.URL
4042import java.security.KeyStore
4143import java.security.cert.Certificate
@@ -128,6 +130,42 @@ class MainActivity : AppCompatActivity() {
128130 }
129131 }
130132
133+ fun sendHttpRequest (view : View ) {
134+ GlobalScope .launch(Dispatchers .IO ) {
135+ onStart(R .id.http_request)
136+ try {
137+ val mURL = URL (" http://amiusing.httptoolkit.tech" )
138+ with (mURL.openConnection() as HttpURLConnection ) {
139+ println (" URL: ${this .url} " )
140+ println (" Response Code: ${this .responseCode} " )
141+ }
142+
143+ onSuccess(R .id.http_request)
144+ } catch (e: Throwable ) {
145+ println (e)
146+ onError(R .id.http_request, e.toString())
147+ }
148+ }
149+ }
150+
151+ fun sendIgnoreProxyHttpRequest (view : View ) {
152+ GlobalScope .launch(Dispatchers .IO ) {
153+ onStart(R .id.ignore_proxy_http_request)
154+ try {
155+ val mURL = URL (" http://amiusing.httptoolkit.tech" )
156+ with (mURL.openConnection(Proxy .NO_PROXY ) as HttpURLConnection ) {
157+ println (" URL: ${this .url} " )
158+ println (" Response Code: ${this .responseCode} " )
159+ }
160+
161+ onSuccess(R .id.ignore_proxy_http_request)
162+ } catch (e: Throwable ) {
163+ println (e)
164+ onError(R .id.ignore_proxy_http_request, e.toString())
165+ }
166+ }
167+ }
168+
131169 fun sendUnpinned (view : View ) {
132170 GlobalScope .launch(Dispatchers .IO ) {
133171 onStart(R .id.unpinned)
0 commit comments