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

custom Header not sent #1441

Open
mschfh opened this issue Jun 14, 2024 · 8 comments · May be fixed by #1561
Open

custom Header not sent #1441

mschfh opened this issue Jun 14, 2024 · 8 comments · May be fixed by #1561
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mschfh
Copy link
Contributor

mschfh commented Jun 14, 2024

Lychee ignores the --header argument:

Steps to reproduce:

start local http server:

nc -lvp1234

Run lychee (tested with v0.15.1) with --header:

lychee 'http://127.0.0.1:1234' --header 'foo=bar'

Lychee should send foo: bar, but doesn't:

Listening on 0.0.0.0 1234
Connection received on localhost 36584
GET / HTTP/1.1
accept: */*
accept-encoding: gzip
host: 127.0.0.1:1234
@mre mre added the bug Something isn't working label Jun 14, 2024
@mre
Copy link
Member

mre commented Jun 14, 2024

Maybe that has something to do with our recent move to https://docs.rs/lychee-lib/latest/lychee_lib/chain/type.RequestChain.html. @thomas-zahner fyi

@thomas-zahner
Copy link
Member

Could not see the headers in netcat even with lychee versions as old as v0.9.0. Does the nc command really show them?

@mre
Copy link
Member

mre commented Jun 14, 2024

Does the nc command really show them?

It does; at least on macOS.

 nc -lv 1234
curl -v -X GET http://localhost:1234 -H "Custom-Header: CustomValue"

Results in the following nc output:

GET / HTTP/1.1
Host: localhost:1234
User-Agent: curl/8.4.0
Accept: */*
Custom-Header: CustomValue

Might be a problem with lychee.

@mschfh
Copy link
Contributor Author

mschfh commented Jun 15, 2024

It seems to affect the initial request, the header is only set for subsequent ones.

@mre
Copy link
Member

mre commented Jun 15, 2024

Strange. I'm not aware of any special handling for the first request. Will need to investigate.

@thomas-zahner
Copy link
Member

thomas-zahner commented Jun 15, 2024

So I think that the --header option currently specifies the headers used for checking the actual links. When you do lychee 'http://127.0.0.1:1234' you tell lychee to check all links on the website http://127.0.0.1:1234 but lychee does not use the headers when fetching that website.

If you do echo https://localhost:1234 | lychee --header 'foo=bar' - you actually check if https://localhost:1234 is a valid link and lychee sends the headers.

Maybe we should also include the headers when fetching a websites content (first case) but maybe we should add a separate option for that. I'm not quite sure.. What are your thoughts @mre?

@mschfh
Copy link
Contributor Author

mschfh commented Jun 15, 2024

As a user, I'd expect it to always send the specified headers on every request, including the initial one. (especially since they are used for authentication in my case)

It'd be nice to have some customizable rules in the config file to include/exclude certain headers for certain hosts, see #1298, but that is a separate issue.

@mre
Copy link
Member

mre commented Sep 27, 2024

Yes, I agree with @mschfh on both points.

@mre mre added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed and removed enhancement New feature or request labels Sep 27, 2024
@mre mre linked a pull request Nov 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants