首页IT科技Apache Commons FileUpload([ApacheSVN] Contents of /httpcomponents/oac.hc3x/trunk/src/examples/BasicAuthenticationExample.java)

Apache Commons FileUpload([ApacheSVN] Contents of /httpcomponents/oac.hc3x/trunk/src/examples/BasicAuthenticationExample.java)

时间2025-07-11 20:09:23分类IT科技浏览4393
导读:55 HttpClient client = new HttpClient( ; 56 57 // pass our credentials to HttpClient, they will only be used for 58...

55 HttpClient client = new HttpClient(); 56 57 // pass our credentials to HttpClient, they will only be used for 58 // authenticating to servers with realm "realm" on the host 59 // "www.verisign.com", to authenticate against 60 // an arbitrary realm or host change the appropriate argument to null. 61 client.getState().setCredentials( 62 new AuthScope("www.verisign.com", 443, "realm"), 63 new UsernamePasswordCredentials("username", "password") 64 ); 65 66 // create a GET method that reads a file over HTTPS, were assuming 67 // that this file requires basic authentication using the realm above. 68 GetMethod get = new GetMethod("https://www.verisign.com/products/index.html"); 69 70 // Tell the GET method to automatically handle authentication. The 71 // method will use any appropriate credentials to handle basic 72 // authentication requests. Setting this value to false will cause 73 // any request for authentication to return with a status of 401. 74 // It will then be up to the client to handle the authentication. 75 get.setDoAuthentication( true );

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
wordpress建站插件(优秀的WordPress自动内链插件-轻松提升网站SEO)