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

Attaching arbitrary headers to requests #187

Closed
rudiejd opened this issue Jan 9, 2024 · 10 comments
Closed

Attaching arbitrary headers to requests #187

rudiejd opened this issue Jan 9, 2024 · 10 comments

Comments

@rudiejd
Copy link

rudiejd commented Jan 9, 2024

hi there, thank you for this plugin! I'd love to use it with my source graph instance, but it is unfortunately hidden behind a reverse proxy. I need to specify a header in every call made to sourcegraph, or provide a cookie that contains this header. What would be the best way of achieving this? I've tried to hack my way through the Lua, specifying this on the RPC call here:

codebase = remote_url,
to no affect

@tjdevries
Copy link
Contributor

So just to be clear, you need to be able to add a special HTTP Header to the requests? I should be able to make that happen if that's what you're saying. I can provide a config point that lets you provide a table with additional headers.

@rudiejd
Copy link
Author

rudiejd commented Jan 12, 2024

@tjdevries yep, that is exactly what I'm saying! I'm also willing to make a PR to add this in if such a contribution would be welcome

@tjdevries
Copy link
Contributor

I can push an update -- there's a bit of ceremony involved for getting a new rust version update, so I'll do that.

The headers are the same for every request? So you can set them ~static at runtime (can update, but doesn't need to update for every request?)?

@rudiejd
Copy link
Author

rudiejd commented Jan 12, 2024

Yep, should be the same for every request in our case.

@tjdevries
Copy link
Contributor

Does what is in #191 give you what you're looking for? To test locally, you should be able to pull the branch down and then run cargo build --all in the repo, and it should pick up the local binaries. I have to do a bit more testing on it, but the idea is in the right direction I think

@rudiejd
Copy link
Author

rudiejd commented Jan 18, 2024

hmmmm, it's still not working for me. SRC_HEADERS should be JSON with { "{header_name}": "{header value}"}, correct?

Could definitely just be an issue somewhere on my side though

@tjdevries
Copy link
Contributor

you would do:

require('sg').setup {
  src_headers = {
    key = value
  }
}

@tjdevries
Copy link
Contributor

you shouldn't have to do the environment variable (I set that to pass information to subprocesses)

@rudiejd
Copy link
Author

rudiejd commented Jan 20, 2024

gotcha, thank you!!! It's sending the right headers, so all good on my end! Thank you TJ!

@tjdevries
Copy link
Contributor

Sorry for the delay, I left sourcegraph but am doing some contracting stuff to support sg.nvim now :) Should be merged and working. Thanks for your patience!

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

No branches or pull requests

2 participants