Git Product home page Git Product logo

gluestick-shared's People

Contributors

christinebrass avatar grabbou avatar jacobmoretti avatar joecortopassi avatar saltycrane avatar straley avatar supergibbs avatar toddw avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gluestick-shared's Issues

Implement proper cookie jar for server side requests

When a web browser receives set-cookie headers in a response from a server it will store those in a "cookie-jar" and send those cookies, as long as they haven't expired in future requests to that domain. Our httpClient in getHttpClient.js makes a good pass at emulating the basics of a cookie jar but it is lacking some functionality. The reason why this is important is for situations where you make multiple API requests on the server before returning a response to the client. If the second request relies on cookies set by the first request, our httpClient will need to send those cookies in it's request. And so on with a third, fourth, etc… requests.

Things that can be improved:

  1. Set-Cookie headers should set cookies per the host settings that a browser would respect. The cookies should only be sent on future requests from a matching domain. Cookies can be set for specific subdomains or they can use a wildcard subdomain. We should follow the same rules.
  2. We should respect expiration of cookies.
  3. Currently the set-cookie header from a request appears to wipe out any of the previous cookies and go with the newly set cookies. This is undesired behavior, it should "merge" them giving a precedence to the new cookies received by the latest Set-Cookie header.

While doing all of that we also forward "all" of the cookies back to the browser. There is a very realistic warning in getHttpClient that talks about mixing multiple api endpoints with server side requests. Currently, I'm not aware of a great solution for that problem other than suggesting all server side API requests should be to the same location. If you must hit a secondary API server that you do not control, it is best to do that after componentDidMount and let the browser handle that. This last part is only partially related to the cookie jar.

Increase test coverage

As this is a "shared" library, it likely requires more attention. I suggest we think of adding few test cases here and there, with the recent PR supporting more middlewares being a good candidate.

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.