Page MenuHomePhabricator

Detect early on if an URL would lead to a PDF for logging
Closed, ResolvedPublic

Description

Context

We want to understand better how often users link to a PDF source and can use it for the autogeneration. Since Citoid does use different approaches to convert an URL to a citation with metadata it would be helpful to get the type of the source early on for logging.

Implementation
  • Check the contentType from the header of the source as early as possible to add the flag to the logging output.
Examples

Works online but is an actually application/octet-stream

Works online but is an actually a pdf

Outcome and Notes
  • We're now logging the sourceContentType when resolving a request
  • There will be cases where the source URL can't be called because it blocks the request for Anti-Spam reasons
  • These cases could still be successful because there might be a DOI detected in the URL that can be resolved elsewhere
  • The sourceContentType will be an empty string then, because the service can't say for sure if the URL actually leads to a pdf source
Logstash outcome

Dashboard that shows successful requests ( status 200 ) but the actual contentType could be detected as PDF

Dashboard that shows failed requests ( status 415 ) and the actual contentType could be detected as PDF ( so we could download the PDF or open it in a browser )

Event Timeline

Change #1320127 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/services/citoid@master] Streamline hostIsAllowed and remove unused flag

https://gerrit.wikimedia.org/r/1320127

Change #1321569 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/services/citoid@master] Convert hostIsAllowed to async/await

https://gerrit.wikimedia.org/r/1321569

Change #1321826 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/services/citoid@master] Streamline and doc unshorten.js

https://gerrit.wikimedia.org/r/1321826

Change #1320127 merged by jenkins-bot:

[mediawiki/services/citoid@master] Streamline hostIsAllowed and remove unused flag

https://gerrit.wikimedia.org/r/1320127

Change #1322921 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/services/citoid@master] Extract methods to get charset and content type

https://gerrit.wikimedia.org/r/1322921

Change #1322927 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/services/citoid@master] Get and log the content type of the source early on

https://gerrit.wikimedia.org/r/1322927

Change #1321826 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/services/citoid@master] Streamline and doc unshorten.js

https://gerrit.wikimedia.org/r/1321826

Change #1322565 had a related patch set uploaded (by WMDE-Fisch; author: WMDE-Fisch):

[mediawiki/services/citoid@master] Convert unshorten to async/await

https://gerrit.wikimedia.org/r/1322565

Change #1321826 merged by jenkins-bot:

[mediawiki/services/citoid@master] Streamline and doc unshorten.js

https://gerrit.wikimedia.org/r/1321826

Change #1322565 merged by jenkins-bot:

[mediawiki/services/citoid@master] Convert unshorten to async/await

https://gerrit.wikimedia.org/r/1322565

Change #1322921 merged by jenkins-bot:

[mediawiki/services/citoid@master] Extract methods to get charset and content type

https://gerrit.wikimedia.org/r/1322921

Change #1322927 merged by jenkins-bot:

[mediawiki/services/citoid@master] Get and log the content type of the original source

https://gerrit.wikimedia.org/r/1322927

Change #1321569 merged by jenkins-bot:

[mediawiki/services/citoid@master] Convert hostIsAllowed to async/await

https://gerrit.wikimedia.org/r/1321569

Let's wait for this to be deployed and then see results from request in production.

Tobi_WMDE_SW claimed this task.