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

Add custom headers to spec #748

Closed
janldk opened this issue Aug 19, 2023 · 6 comments
Closed

Add custom headers to spec #748

janldk opened this issue Aug 19, 2023 · 6 comments

Comments

@janldk
Copy link
Contributor

janldk commented Aug 19, 2023

As per #724 (comment) the usage of the JSON-file for some checkers might require custom headers for the checker to behave as expected.

This is currently a not documented requirement. I suggest adding a headers field to the specs. This should probably NOT contain user-agent as this will change and is error prone, but all other required headers for both the exist and missing checks to pass.

It could be implementet only for those who need it. This will not break backwards compability and prevent bloating of the JSON.

For Github this could look like so:

{
        "name" : "GitHub",
        "uri_check" : "https://github.com/{account}",
        "e_code" : 200,
        "e_string" : "p-nickname vcard-username d-block",
        "m_string" : "<title>Page not found ",
        "m_code" : 404,
        "known" : ["test", "WebBreacher"],
        "cat" : "coding",
        "headers": {
                "accept": "text/html"
        }
}

As @WebBreacher mentions the http2 pseudo-header authority in his example a suggestion in the future might be specifying if a specific version of HTTP is required for the given checker.

Github however does not require HTTP2.

@WebBreacher
Copy link
Owner

And interesting and quite useful addition. I like it. An optional headers parameter for those sites requiring it. This would give the downstream checkers more information about how to make a successful query....or they can ignore it altogether.

Anyone else have thoughts about this?

@WebBreacher
Copy link
Owner

@janbinx do you know of other sites in WMN now or that are not in WMN that would use this headers parameter?

@janldk
Copy link
Contributor Author

janldk commented Sep 13, 2023

Sorry for the late reply. Well, Insta would be one. It uses a x-ig-app-ish on an internal API to query username w/o login

WebBreacher added a commit that referenced this issue Sep 17, 2023
Added `"headers": {}` as valid parameter in the JSON file.
@WebBreacher
Copy link
Owner

I see no downside to this and have altered the schema and submitted it to the project. @janbinx can you adjust the submitted PR to add this header?

@janldk
Copy link
Contributor Author

janldk commented Oct 10, 2023

It seems you've set the type for the headers to array, not object. This means that if one wants to add key/value pairs it needs to be done like this:

headers: [
    {"accept": "application/json"},
    {"x-request-for": "you get the idea"}
]

Wouldn't it make more sense to cast it as an object and do this instead:

headers: {
    "accept": "application/json",
    "x-request-for": "you get the idea"
}

That would certainly be the way you'd use it in a script.

I've updated the PR for Github as we discussed previously (I totally missing this, sorry), but currently the PR fails the JSON-checkers as the specs expects an array.

WebBreacher added a commit that referenced this issue Oct 14, 2023
As @janbinx suggested the proper format for the `headers` parameter is an `object` not `array` as I had made it. Fixing it.
WebBreacher added a commit that referenced this issue Oct 14, 2023
@WebBreacher
Copy link
Owner

Absolutely agree and that was my bad for not understanding the differences between arrays and objects in JSON. I've adjusted the schema.

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