Skip to content

Fallback to GET for 500 responses. #224

@Pigankle

Description

@Pigankle

if response.status_code in [HTTPStatus.BAD_REQUEST, HTTPStatus.METHOD_NOT_ALLOWED]:

Some servers return 500 to HEAD requests but 200 to GET. The current fallback only retries with GET on 400 and 405. This adds 500 to that list so those URLs will be rechecked (and not incorrectly marked as broken.)
An example of such a site:
https://swefc.unm.edu/home/resources/?_sft_topic=water-conservation

# Fails (HEAD request - what linkcheck uses)
curl -I "https://swefc.unm.edu/home/resources/?_sft_topic=water-conservation"

# Succeeds (GET request - what browsers use)
curl -L "https://swefc.unm.edu/home/resources/?_sft_topic=water-conservation"

I think the fix would be changing line 413 from

            if response.status_code in [HTTPStatus.BAD_REQUEST, HTTPStatus.METHOD_NOT_ALLOWED]:

to

            if response.status_code in [HTTPStatus.BAD_REQUEST, HTTPStatus.METHOD_NOT_ALLOWED, HTTPStatus.INTERNAL_SERVER_ERROR]:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions