The l10n_update module defines the constant L10N_UPDATE_DEFAULT_SERVER_PATTERN as the default server pattern for the translations. This constant currently uses the HTTP protocol.

drupal.org has adopted HTTPS as the default protocol for all its services. When a client request an URI using HTTP protocol, the response redirect the client to the corresponding HTTPS URI.

As a result of this, the module makes two request everytime it verifies the existence of a translation file. The first one to the HTTP URI and the second one following the 301 header from the reponse of the first request.

These calls are made on the function l10n_update_http_request, which is called when the function l10n_update_batch_status_check runs.

When the first function is executed, it makes a first request on the line 257 of the l10n_update.http.inc file.

HEAD /files/translations/7.x/l10n_update/l10n_update-7.x-2.1.es.po HTTP/1.0
User-Agent: Drupal (+http://drupal.org/)
Host: ftp.drupal.org

Receiving this response:

HTTP/1.1 301 Moved Permanently
...
Location: https://ftp-origin.drupal.org/files/translations/7.x/l10n_update/l10n_update-7.x-2.1.es.po
...

After checking the HTTP response satus code, the module makes the second request:

HEAD /files/translations/7.x/l10n_update/l10n_update-7.x-2.1.es.po HTTP/1.0
User-Agent: Drupal (+http://drupal.org/)
Host: ftp-origin.drupal.org

This time the response contains the translation file:

HTTP/1.1 200 OK
...
Content-Type: application/octet-stream
Last-Modified: Sat, 03 Dec 2016 12:43:47 GMT
...
Content-Length: 17042
...

This behavior could be modified by changing the L10N_UPDATE_DEFAULT_SERVER_PATTERN constant to use the HTTPS protocol.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tucho created an issue. See original summary.

tucho’s picture

I made a patch that updates the L10N_UPDATE_DEFAULT_SERVER_PATTERN constant, so now it uses HTTPS.

Also, the patch updates the links to the Drupal sites on the README and the inline documentation.

Now the module only makes a request per file when refreshing the available translations.

Sutharsan’s picture

Also, the patch updates the links to the Drupal sites on the README and the inline documentation.

This makes the patch much harder to check.

Sutharsan’s picture

I'm wondering whether we should update any variables (a.o. l10n_client_server) that are set to old default value.

tucho’s picture

Hi @Sutharsan!

You're right. Making the documentation changes with the same patch adds a lot of modifications, when only 2 lines must be changed.

I uploaded a new patch that contains only the constant L10N_UPDATE_DEFAULT_SERVER_PATTERN and the variable l10n_client_server changes.

I also added a hook_update that updates the l10n_client_server value if it have the original value on the database.

I will create a different issue for the documentation changes.

Regards
Cristian

Sutharsan’s picture

FileSize
810 bytes

I've added another variable to the hook_update.
Only an interdiff provided for reference.

  • Sutharsan committed c9884e7 on 7.x-2.x authored by tucho
    Issue #2907795 by tucho, Sutharsan: Prefer HTTPS protocol over HTTP when...
Sutharsan’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.