geeteam / gtapp-android Goto Github PK
View Code? Open in Web Editor NEWthe android SDK of geetest
the android SDK of geetest
问题发生在在 Geetest.java 里面,
当我是用 https 请求时,会出现 Exception: Already Connected 异常,原因在于 171 行代码 sslReadConnection.getHeaderFields() 实际上已经打开了连接,所以后续在 181 行 sslReadConnection.setDoInput(true); 调整连接的属性时会报错。
可以参考StackOverflow
HttpsURLConnection sslReadConnection = (HttpsURLConnection) url.openConnection(); mSSLReadConnection = sslReadConnection; cookieManager = new CookieManager(); Map> headerFields = sslReadConnection.getHeaderFields(); if (headerFields.get("Set-Cookie") != null) { List cookiesHeader = headerFields.get("Set-Cookie"); if(cookiesHeader != null) { for (String cookie : cookiesHeader) { cookieManager.getCookieStore().add(null, HttpCookie.parse(cookie).get(0)); } } } sslReadConnection.setDoInput(true); sslReadConnection.setDoOutput(false); sslReadConnection.setRequestMethod("GET"); sslReadConnection.setConnectTimeout(mTimeout/2); sslReadConnection.setReadTimeout(mTimeout/2); sslReadConnection.connect();
HttpsURLConnection sslReadConnection = (HttpsURLConnection) url.openConnection(); mSSLReadConnection = sslReadConnection; cookieManager = new CookieManager(); sslReadConnection.setDoInput(true); sslReadConnection.setDoOutput(false); sslReadConnection.setRequestMethod("GET"); sslReadConnection.setConnectTimeout(mTimeout/2); sslReadConnection.setReadTimeout(mTimeout/2); sslReadConnection.connect(); Map> headerFields = sslReadConnection.getHeaderFields(); if (headerFields.get("Set-Cookie") != null) { List cookiesHeader = headerFields.get("Set-Cookie"); if(cookiesHeader != null) { for (String cookie : cookiesHeader) { cookieManager.getCookieStore().add(null, HttpCookie.parse(cookie).get(0)); } } }
在加载验证码需要的图片时,chromium给出的log信息是:
I/chromium: [INFO:CONSOLE(0)] "Image from origin 'XXXX' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://115.28.113.153' is therefore not allowed access.", source: http://115.28.113.153/static/appweb/app-index.html?XXXX
请问这种问题该如何解决呢?
文档里面没有说明需要哪些权限,最少能运行的权限是?
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.