Giter Club home page Giter Club logo

Comments (2)

vegasm avatar vegasm commented on September 17, 2024

I implemented a solution to our problem which allows to do the process using only one session. The approach makes use of a new HttpSession class (HttpCloseableSession) which has CookieStore, HttpContext, CredentialsProvider and CloseableHttpClient.
This CloseableHttpClient is built by using the builder which allows you to set the proxy and the configs you’ve done in the HTTPSession setting area. I also created a new HTTPCloseableMethod class which has a similar approach to the original one but using the new features.

Finally, I added two new methods to HTTPFactory to use a custom GET and HEAD. The new methods only need the URL because the HTTPCloseableSession is static. The new HTTPCloseableMethod accepts a HTTPSession.Methods and contains the execute method. When the opendap calls to this get, it is able to call execute and close the client (you can take a look to DConnect2.java

How can we make a request now?

It is very simple:

HTTPCloseableSession.setCredentials("username", "password");
HTTPCloseableMethod method = HTTPFactory.GET(urlString);
int statusCode = method.execute();
is = method.getResponseAsStream();
method.close();

You can see my approach is ready to basic authentication but can be used with others. I've tried not to modify so much of your code, only the esential part to make it work but I think it can be a good way to start.

Please take a look

from thredds.

DennisHeimbigner avatar DennisHeimbigner commented on September 17, 2024

The deprecations are because we were forced to switch to Apache httpclient 4.4.x
before we were ready. The existing code is based on Apache httpclient 4.3.x.
The 4.4 code is substantially refactored compared to 4.3. The 4.3 API is supported,
but deprecated, so that is why you are seeing them.
The complete conversion of the code to 4.4 is underway, but probably will not
be available until version 5 of thredds.
BTW, you say "my approach is ready to basic authentication but can be used with others."
Can you give specifics, say for URS. We already or plan to support a wide variety of authorization mechanisms: Basic, ESG (client-side certificates), URS (redirection) and soon to be others.

from thredds.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.