Problem/Motivation

Certain pages return 404 when making a HEAD request, but they return 200 if GET is used; in this case the broken links report would be inaccurate and report correct pages as incorrect. For many sites with many links it would require a lot of work to change each individual link to GET.

Steps to reproduce

Create a page with a link to page that behaves like described in 'Motivation' (e.g. https://www.bible.com/bible/3290/MAT.1.MTHB). Then run checking the links and see the report.

Proposed resolution

Create a GET fallback for HEAD requests. If a HEAD request fails, a GET request to the target link would be called.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Livecan created an issue. See original summary.

eiriksm’s picture

Great suggestion.

This would have to be opt in, so make it configurable at least

Are you able to suggest something in a merge request or s patch?

Livecan’s picture

Here's the suggested change to get the idea: https://git.drupalcode.org/issue/linkchecker-3334240/-/commit/294a184e04....
We could have it configurable - have a checkbox in the config form? And maybe use default setting as fallback enabled for new installation but for existing installation leave the current behavior?
I could include the changes to the form and create the config tomorrow and put it here.

joelpittet’s picture

Version: 8.x-1.0-beta6 » 8.x-1.x-dev

Livecan’s picture

Sorry, had some problems with figuring out submitting my changes to the project. I hope now it should be really ready to merge.

eiriksm’s picture

Status: Active » Needs review

bwaindwain made their first commit to this issue’s fork.

bwaindwain’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

Switched to 2.0.x branch and added a new branch and merge request for this feature.

anybody’s picture

Version: 2.0.x-dev » 2.1.x-dev

I agree this still makes sense as option, as several hosts refuse HEAD calls, for example:

  • Google
  • Amazon
  • Facebook
  • Pexels
  • ...

Which leads to failing / false-positive broken link checkes especially in the imprint.

anybody’s picture

Assigned: Livecan » Unassigned

@bwaindwain could you change the target branch to 2.1.x please?

Implementation looks nice, we should get this over the finish line! :)

anybody’s picture

Status: Needs review » Needs work

I also left a comment in code.

I tried this and for many links it works and links are marked correct now. But some still are marked failed, for example:

Yes, EXACTLY this URLs! Give it a try. Any idea for the reasons, if it's already GET, not HEAD?

konot changed the visibility of the branch 3334240-use-get-method to hidden.

konot changed the visibility of the branch 3334240-use-get-method to hidden.

xfxfca’s picture

StatusFileSize
new1.42 KB

try 'GET' if 'HEAD' fails

joseph.olstad made their first commit to this issue’s fork.

joseph.olstad’s picture

Assigned: Unassigned » joseph.olstad
Status: Needs work » Active
joseph.olstad’s picture

@xfxfca please back off your patch and test the latest MR here:

https://git.drupalcode.org/project/linkchecker/-/merge_requests/120.diff

need to confirm if this works.

xfxfca’s picture

StatusFileSize
new1.36 KB
xfxfca’s picture

updated patch

joseph.olstad’s picture

Assigned: joseph.olstad » Unassigned
Status: Active » Needs review

Please review MR 120

joseph.olstad’s picture

The small patch is from MR120.

The larger patch is from the double issue MR121.

joelpittet changed the visibility of the branch 2.0.x to hidden.

joelpittet changed the visibility of the branch 3334240-use-get-method-2 to hidden.

joelpittet’s picture

There are quite a few proposed solutions here, and it’s not clear which one is meant to move forward. I hid two that looked like accidental MRs (hopefully correctly!).

The issue summary is excellent though! Short, clear, and the title is specific. That really helps. Let’s make it easy for maintainers to commit something.

@joseph.olstad instead of me trying to guess, maybe you could hide any MRs/branches we no longer need? If you’re combining approaches, a patch might be a better fit anyway, since it’s composer-patchable and avoids branch clutter.

I think most of this confusion came from creating a 2.0.x target branch on a fork that didn’t already have it — GitLab makes you create it before you can select it as the MR target, which unintentionally makes it look like it’s part of the issue work. (I still haven’t figured out how to avoid that either.)

joseph.olstad changed the visibility of the branch 3334240-get-method-fallback-with-3213210-host-port-substitution to hidden.

joseph.olstad’s picture

I will argue that MR 56 is not needed since linkchecker already offers a domain blacklist to handle the option.

MR 120 has been extensively tested and also passes automated testing.

joseph.olstad changed the visibility of the branch 3334240-use-get-method-2.0.x to hidden.

joelpittet’s picture

Let’s make this simple, which MR only does what the issue summary and title asks of it and doesn’t creep on scope?

joseph.olstad’s picture

Answer: MR 120 and it is the only currently visible MR

joelpittet’s picture

Thanks @joseph.olstad I will reviewMR 121 later, first glance the test could use something a bit more explicit, but I will look closer as there is probably context lines that make it clearer already in place.

joelpittet’s picture

The code looks great I should add, I am mostly concerned about the test

joseph.olstad’s picture

MR 120

This one

anybody’s picture

@joelpittet looks like you accidentally checked MR121 instead of MR120 as @joseph.olstad pointed out in #44?

@joseph.olstad the MR looks good and clear to me, I just left two notes, maybe you'd like to have a look.

I agree this is very helpful and should get released soon.