org.apache.http.protocol.BasicHttpContext#setAttribute ( )源码实例Demo

下面列出了org.apache.http.protocol.BasicHttpContext#setAttribute ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: neembuu-uploader   文件: JunoCloudAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from JunoCloud.me");
    //responseString = NUHttpClientUtils.getData("http://junocloud.me", httpContext);
}
 
源代码2 项目: neembuu-uploader   文件: NetUAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from NetU.tv");
    //responseString = NUHttpClientUtils.getData("http://netu.tv", httpContext);
}
 
源代码3 项目: neembuu-uploader   文件: VidXdenAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from VidXden.com");
    //responseString = NUHttpClientUtils.getData("http://vidxden.com", httpContext);
}
 
源代码4 项目: neembuu-uploader   文件: RyuShareAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from RyuShare.com");
    //stringResponse = NUHttpClientUtils.getData("http://ryushare.com/", httpContext);
}
 
源代码5 项目: neembuu-uploader   文件: VidToAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from VidTo.me");
    //responseString = NUHttpClientUtils.getData("http://vidto.me", httpContext);
}
 
private HttpResponse login(BonitaCredentials credentials) throws IOException {
    BasicHttpContext httpContext = new BasicHttpContext();
    BasicCookieStore cookieStore = new BasicCookieStore();
    httpContext.setAttribute("http.cookie-store", cookieStore);
    List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
    urlParameters.add(new BasicNameValuePair("username", credentials.username));
    urlParameters.add(new BasicNameValuePair("password", credentials.password));
    urlParameters.add(new BasicNameValuePair("redirect", "false"));
    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(urlParameters, "utf-8");
    HttpPost postRequest = new HttpPost(credentials.loginServletURI);
    postRequest.setEntity(entity);
    return getProxyClient().execute(postRequest, httpContext);
}
 
源代码7 项目: neembuu-uploader   文件: FileViceAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from FileVice.com");
    //responseString = NUHttpClientUtils.getData("http://filevice.com", httpContext);
}
 
源代码8 项目: neembuu-uploader   文件: TurboVideosAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from TurboVideos.net");
    //responseString = NUHttpClientUtils.getData("", httpContext);
}
 
源代码9 项目: neembuu-uploader   文件: UpZeroSevenAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from Up07.net");
    //responseString = NUHttpClientUtils.getData("http://up07.net", httpContext);
}
 
源代码10 项目: neembuu-uploader   文件: FileRioAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from FileRio.in");
    //responseString = NUHttpClientUtils.getData("http://filerio.in", httpContext);
}
 
源代码11 项目: neembuu-uploader   文件: VShareAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("Getting startup cookies & link from VShare.eu");
    responseString = NUHttpClientUtils.getData("http://vshare.eu/login.html", httpContext);
    redirect = StringUtils.stringBetweenTwoStrings(responseString, "name=\"redirect\" value=\"", "\"");
}
 
源代码12 项目: neembuu-uploader   文件: UsersFilesAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("Getting startup cookies & link from UsersFiles.com");
    responseString = NUHttpClientUtils.getData("https://usersfiles.com/", httpContext);
    
    doc = Jsoup.parse(responseString);
    rand = doc.select("form[name=FL]").select("input[name=rand]").attr("value");
}
 
源代码13 项目: neembuu-uploader   文件: VideoWoodAccount.java
private void initialize() throws Exception {
       httpContext = new BasicHttpContext();
       cookieStore = new BasicCookieStore();
       httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

       NULogger.getLogger().info("Getting startup cookies & link from VideoWood.tv");
       responseString = NUHttpClientUtils.getData("http://videowood.tv/login", httpContext);
       doc = Jsoup.parse(responseString);
vdwood_token = doc.select("form").select("input[name=_token]").attr("value");
   }
 
源代码14 项目: neembuu-uploader   文件: VideoMegaAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from VideoMega.tv");
    //responseString = NUHttpClientUtils.getData("http://videomega.tv", httpContext);
}
 
源代码15 项目: neembuu-uploader   文件: UltraMegaBitAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("Getting startup cookies & link from UltraMegaBit.com");
    responseString = NUHttpClientUtils.getData("https://ultramegabit.com/login", httpContext);
    csrf_token = Jsoup.parse(responseString).select("input[name=csrf_token]").val();
}
 
源代码16 项目: neembuu-uploader   文件: MegaCacheAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from MegaCache.net");
    //responseString = NUHttpClientUtils.getData("http://megacache.net", httpContext);
}
 
源代码17 项目: neembuu-uploader   文件: KeepTwoShareAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from Keep2Share.cc");
    //responseString = NUHttpClientUtils.getData("http://keep2share.cc/", httpContext);
}
 
源代码18 项目: neembuu-uploader   文件: FilePupAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
}
 
public MTGDesignPicturesProvider() throws IOException {
	super();
	cookieStore = new BasicCookieStore();
	httpContext = new BasicHttpContext();
	httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
}
 
源代码20 项目: OpenAs2App   文件: HTTPUtil.java
/**
 * Execute a request via HTTP
 *
 * @param method         GET, PUT, POST, DELETE, etc
 * @param url            The remote connection string
 * @param headers        HTTP headers to be sent
 * @param params         Parameters for the get. Can be null.
 * @param inputStream    Source stream for retrieving request data
 * @param options        Any additional options for affecting request behaviour. Can NOT be null.
 * @param noChunkMaxSize The maximum size before chunking would need to be utilised. 0 disables check for chunking
 * @return ResponseWrapper
 * @throws Exception
 */
public static ResponseWrapper execRequest(String method, String url, Enumeration<Header> headers, NameValuePair[] params, InputStream inputStream, Map<String, String> options, long noChunkMaxSize) throws Exception {

    HttpClientBuilder httpBuilder = HttpClientBuilder.create();
    URL urlObj = new URL(url);
    /*
     * httpClient is used for this request only,
     * set a connection manager that manages just one connection.
     */
    if (urlObj.getProtocol().equalsIgnoreCase("https")) {
        /*
         * Note: registration of a custom SSLSocketFactory via httpBuilder.setSSLSocketFactory is ignored when a connection manager is set.
         * The custom SSLSocketFactory needs to be registered together with the connection manager.
         */
        SSLConnectionSocketFactory sslCsf = buildSslFactory(urlObj, options);
        httpBuilder.setConnectionManager(new BasicHttpClientConnectionManager(RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", sslCsf).build()));
    } else {
        httpBuilder.setConnectionManager(new BasicHttpClientConnectionManager());
    }

    RequestBuilder rb = getRequestBuilder(method, urlObj, params, headers);
    RequestConfig.Builder rcBuilder = buildRequestConfig(options);
    setProxyConfig(httpBuilder, rcBuilder, urlObj.getProtocol());
    rb.setConfig(rcBuilder.build());

    if (inputStream != null) {
        if (noChunkMaxSize > 0L) {
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            long copied = IOUtils.copyLarge(inputStream, bout, 0L, noChunkMaxSize + 1, new byte[8192]);
            if (copied > noChunkMaxSize) {
                throw new IOException("Mime inputstream too big to put in memory (more than " + noChunkMaxSize + " bytes).");
            }
            ByteArrayEntity bae = new ByteArrayEntity(bout.toByteArray(), null);
            rb.setEntity(bae);
        } else {
            InputStreamEntity ise = new InputStreamEntity(inputStream);
            rb.setEntity(ise);
        }
    }
    final HttpUriRequest request = rb.build();

    String httpUser = options.get(HTTPUtil.PARAM_HTTP_USER);
    String httpPwd = options.get(HTTPUtil.PARAM_HTTP_PWD);
    if (httpUser != null) {
        CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
        credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(httpUser, httpPwd));
        httpBuilder.setDefaultCredentialsProvider(credentialsProvider);
    }
    BasicHttpContext localcontext = new BasicHttpContext();
    BasicScheme basicAuth = new BasicScheme();
    localcontext.setAttribute("preemptive-auth", basicAuth);
    try (CloseableHttpClient httpClient = httpBuilder.build()) {
        ProfilerStub transferStub = Profiler.startProfile();
        try (CloseableHttpResponse response = httpClient.execute(request, localcontext)) {
            ResponseWrapper resp = new ResponseWrapper(response);
            Profiler.endProfile(transferStub);
            resp.setTransferTimeMs(transferStub.getMilliseconds());
            for (org.apache.http.Header header : response.getAllHeaders()) {
                resp.addHeaderLine(header.toString());
            }
            return resp;
        }
    }
}