question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get header value from Streaming.

See original GitHub issue

Hello!

I do have a simple endpoint that streams objects from the database. In headers, I’m sending extra header with information about the total amount of items. The header is called total_count

Zrzut ekranu 2021-10-26 o 00 37 59

I’m seeing the value in the response header in the network debugger. However, I’m unable to get it using your framework.

const headers = new grpc.Metadata();
headers.set('authorization', login?.accessToken || '');
const response = client.listDemoObjects(req, headers);
const items: DemoObject.AsObject[] = [];
let totalItems: number;

response.on('status', (status) => {
  console.log(status.code);
  console.log(status.details);
  console.log(status.metadata); // total_count is not here
});

response.on('end', (status) => {
  console.log(status); // total_count is not here
});

response.on('data', (data) => {
  items.push(data.toObject()); // total_count is not here
});

How can I get response headers?

To be 100% clear I’m not using trailers. 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lukasmoellerchcommented, Nov 11, 2021

As noted here you should be able to read the response headers in the "metadata" event. The GrpcWebClientReadableStream implementation directly reads the response headers from the xhr event and will emit the corresponding event.

0reactions
singerxtcommented, Nov 23, 2022

Hello!

You have to add an additional header in the envoy server so that grpc lib will be able to use it. In my case it was.

expose_headers: grpc-status,grpc-message,total_items

I’m closing this issue as not an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get the header values from streaming API response
We are using Icecast streaming server for online radio, how do we get the api response header values. like. icy-description: Online Radio ...
Read more >
Configuring HTTP Headers, Streaming, and Buffering (Real ...
Use the Set HTTP Response Code VI and the Set HTTP Response MIME Type VI to customize the response code and MIME type...
Read more >
How to Read HTTP Headers in Spring REST Controllers
First, we'll be using the @RequestHeader annotation to read headers individually as well as all together. After that, we'll take a deeper look ......
Read more >
IHTTPResponse (Wowza Streaming Engine 4 API)
Method Summary ; Get header value · Get the current response headers as a map · Get the size in bytes of the...
Read more >
Replace a header value with stream - DevCentral
In the response, i get a 302 back. in this 302er I want to replace the protocol. ... enabled for subsequent HTTP requests...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found