Allow set http headers for drupal_http_request on configuration form. In my case, I need to disallow direct URL access to images on production site with code in .htaccess similar to

# Disallow direct URL access to images.
  RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?example.com [NC]
  RewriteRule .*\.(jpg|jpeg|png|gif)$ - [NC,F,L]

But I still want to load images from production to local machine. So, I'd like to set Referer header for the request.

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sergei_brill created an issue. See original summary.

sergei_brill’s picture

Status: Active » Needs review
FileSize
1.94 KB
asrob’s picture

Version: 7.x-1.7 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Tested it, works well, RTBC'ed.

greggles’s picture

@asrob can you create and 8.x patch based on this?

asrob’s picture

@greggles, sure, I'll try to create one. :)

BarisW’s picture

Any luck @asrob?

  • axel.rutz committed 654528b on 7.x-1.x authored by asrob
    Issue #2611830 by sergei_brill, asrob: Allow set http headers for...
  • axel.rutz committed e4064fd on 7.x-1.x
    Added minor amendments and variable integration to #2611830
    

BarisW credited axel.rutz.

BarisW’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
jklmnop’s picture

has anyone successfully ported a d8 patch for this feature?

jklmnop’s picture

Here's a 8.x-1.1 patch. Not sure if it will work on the dev branch, although the test says it passes for that too. It's a port of 7.x-1.x patch.

jklmnop’s picture

Here's a patch for the 8.x-1.2 release

jklmnop’s picture

Here's a patch for 1.4.0 (8.x-1.4)

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

smustgrave’s picture

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

  • smustgrave committed 874ad553 on 8.x-1.x
    Issue #2611830: Allow set http headers for request
    
smustgrave’s picture

Status: Patch (to be ported) » Fixed

Backported to the 2.0.x branch.

If someone could text the dev branch a bit I'll do a release in the next few days.

Status: Fixed » Closed (fixed)

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

uniquename’s picture

Here is a patch against current 2.0.x