Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward headers to grpc hook java #1112

Closed
TaridaGeorge opened this issue Apr 16, 2024 · 2 comments · Fixed by #1188
Closed

Forward headers to grpc hook java #1112

TaridaGeorge opened this issue Apr 16, 2024 · 2 comments · Fixed by #1188
Labels

Comments

@TaridaGeorge
Copy link
Contributor

TaridaGeorge commented Apr 16, 2024

I have an angular app which has an upload file feature. On the frontend side I'm using tus-js-client, the tusd server is v2.4.0 and the hook is grpc. From the frontend, I upload the file with the Authorization header but the tusd doesn't seem to pass them to the grpc server that I have written in Java. Is there an option that I should enable in order for the Authorization token to be passed to my java app?

Is there an option to enable more logging in tusd in order for me to see also the headers that are send from tus-js-client to it?
In my java app, I can see that on the grpc hook I have no headers.

Setup details
Please provide following details, if applicable to your situation:

  • Operating System: Linux
  • Used tusd version: v2.4.0
  • Used tusd data storage: disk store
  • Used tusd configuration: --hooks-grpc 192.168.1.201:7333 --hooks-grpc-retry 5 --hooks-enabled-events "pre-create,post-create,post-receive,post-terminate,post-finish,pre-finish"
    -upload-dir=/opt/tusd/uploads/
  • Used tus client library: tus-js-client
const upload = new tus.Upload(file, {
  endpoint: "http://172.17.0.1:1080/files",
  retryDelays: [0, 3000, 5000],
  metadata: metadata,
  onError: (error) => {
	  reject(error);
  },
  headers: {
	  Authorization: `Bearer ${metadata['authToken']}`,
  },
  onShouldRetry: function (err: any, retryAttempt, options) {
	  // omited
	  return true;
  },
  onProgress: (bytesUploaded, bytesTotal) => {
	  const percentage = (bytesUploaded / bytesTotal) * 100;
	  progressCallback(percentage.toFixed(2));
  },
  onSuccess: () => {
	  resolve(upload);
  },
});
  
upload.start();
@Acconut
Copy link
Member

Acconut commented Apr 17, 2024

Headers from the incoming requests are not attached to HTTP/2 requests for gRPC. Such an option to forward HTTP headers is only available for HTTP hooks (see the flag).

However, the headers from the incoming requests are also provided in the payload provided via gRPC:

// Header contains all HTTP headers as present in the HTTP request.
map <string, string> header = 4;

@TaridaGeorge
Copy link
Contributor Author

TaridaGeorge commented Apr 17, 2024

Indeed. I've created a PR to handle those shortcomings. Please see #1114

Only this line need to be modified:

https://github.com/tus/tusd/pull/1114/files#diff-02dbee1afbbc2d3019a64b4337548b6408b150fdafd5d9960145f692df7295b7R95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants