Java Code Examples for org.apache.http.protocol.BasicHttpContext#setAttribute()

The following examples show how to use org.apache.http.protocol.BasicHttpContext#setAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TurboVideosAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: KeepTwoShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: MegaCacheAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: UltraMegaBitAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example 5
Source File: VideoMegaAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: VideoWoodAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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");
   }
 
Example 7
Source File: UsersFilesAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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");
}
 
Example 8
Source File: VShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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=\"", "\"");
}
 
Example 9
Source File: FileRioAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 10
Source File: UpZeroSevenAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: JunoCloudAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: FileViceAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 13
Source File: PreservingCookiePathProxyServlet.java    From bonita-ui-designer with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 14
Source File: VidToAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 15
Source File: RyuShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: VidXdenAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 17
Source File: NetUAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 18
Source File: HTTPUtil.java    From OpenAs2App with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * 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;
        }
    }
}
 
Example 19
Source File: MTGDesignPicturesProvider.java    From MtgDesktopCompanion with GNU General Public License v3.0 4 votes vote down vote up
public MTGDesignPicturesProvider() throws IOException {
	super();
	cookieStore = new BasicCookieStore();
	httpContext = new BasicHttpContext();
	httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
}
 
Example 20
Source File: FilePupAccount.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
}