Skip to content

Server side language headers#1981

Merged
tdonohue merged 2 commits intoDSpace:mainfrom
atmire:w2p-96121_server-side-language-headers
Dec 16, 2022
Merged

Server side language headers#1981
tdonohue merged 2 commits intoDSpace:mainfrom
atmire:w2p-96121_server-side-language-headers

Conversation

@YanaDePauw
Copy link
Copy Markdown
Contributor

@YanaDePauw YanaDePauw commented Dec 1, 2022

References

Description

This PR fixes the issue with the browser languages not being added to the Accept-Language header for server side requests.

Instructions for Reviewers

Reproducing this issue requires inspecting the "Accept-Language" header of server side calls which aren't visible in the network tab of a browser.
The easiest way to achieve this is to hook a backend you can debug to the angular application and then debug the incoming calls and compare the headers from the server side calls and the client side calls.

An example on how to do this is the following:

  1. Set up a backend instance and hook this to the front end
  2. Run the front end in production mode
  3. Make sure your browser languages and the repository language are different.
  4. Set a breakpoint in the SiteRestRepository on the first line of the findOne method.
  5. In the angular app, open the network tab and navigate to the repository home page.
  6. When the code initially stops at the breakpoint, check the user-agent of the request by using the following command:``````
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("user-agent");
  7. Verify this contains node.js in the value.
  8. Retrieve the "Accept-Language" header by running:
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("Accept-Language");
  9. Verify that this list contains the main UI language and your browser languages
  10. Continue the code, and keep continuing until you requests start showing up in the network tab. This means that client side calls will start coming in into the back end.
  11. When the code stops again at the breakpoint, retrieve the user agent again:
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("user-agent");
  12. Verify that it does NOT contain node.js in the value.
  13. Retrieve the "Accept-Language" header by running:
    getRequestService().getCurrentRequest().getHttpServletRequest().getHeader("Accept-Language");
  14. Verify that this list also contains both the UI language and your browser languages and is similar to the server side request.

Checklist

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes TSLint validation using yarn run lint
  • My PR doesn't introduce circular dependencies
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new, third-party dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.

@tdonohue tdonohue added bug 1 APPROVAL pull request only requires a single approval to merge labels Dec 1, 2022
@tdonohue tdonohue added this to the 7.5 milestone Dec 1, 2022
@tdonohue tdonohue self-requested a review December 8, 2022 15:55
Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @YanaDePauw ! The code looks good to me & I've verified it has no side effects that I can see.

@tdonohue tdonohue merged commit 34e60df into DSpace:main Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Server side language headers

2 participants