Merge lp:~gesha/linaro-license-protection/non-standart-http-port into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Merged at revision: 36
Proposed branch: lp:~gesha/linaro-license-protection/non-standart-http-port
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 44 lines (+14/-4)
1 file modified
.htaccess (+14/-4)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/non-standart-http-port
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+88453@code.launchpad.net

Description of the change

Added handling of non-standart http port in .htaccess
Mostly needed for testing, but who knows...

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

Just to clarify, this is a pre-requisite for https://code.launchpad.net/~gesha/linaro-license-protection/clickthrough-testing/+merge/88387?

Also, it would be nice to add some comments about what do the new rewriterules do on lines 8-14 (i.e. "We set environment variable CO_DOMAIN to just the domain without the port to use for setting a cookie.").

Otherwise, looks good.

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Also, you can make that entire block 'simpler' by using slightly more complex RE:

 RewriteCond %{HTTP_HOST} ^([^\:]*)(\:.*)$
 RewriteRule .* - [E=CO_DOMAIN:%1]

Revision history for this message
Georgy Redkozubov (gesha) wrote :

> Just to clarify, this is a pre-requisite for https://code.launchpad.net/~gesha
> /linaro-license-protection/clickthrough-testing/+merge/88387?
>
> Also, it would be nice to add some comments about what do the new rewriterules
> do on lines 8-14 (i.e. "We set environment variable CO_DOMAIN to just the
> domain without the port to use for setting a cookie.").
>
> Otherwise, looks good.

Yes, just to separate the activity :)

> Also, you can make that entire block 'simpler' by using slightly more complex
> RE:
>
>
> RewriteCond %{HTTP_HOST} ^([^\:]*)(\:.*)$
> RewriteRule .* - [E=CO_DOMAIN:%1]

Unfortunately it won't work for port 80

37. By Georgy Redkozubov

Added comments about new RewriteRule

Revision history for this message
Данило Шеган (danilo) wrote :

Uhm, I forgot ? after the second group:

         RewriteCond %{HTTP_HOST} ^([^\:]*)(\:.*)?$
         RewriteRule .* - [E=CO_DOMAIN:%1]

This should work for port 80 as well.

Revision history for this message
Georgy Redkozubov (gesha) wrote :

> Uhm, I forgot ? after the second group:
>
>
> RewriteCond %{HTTP_HOST} ^([^\:]*)(\:.*)?$
> RewriteRule .* - [E=CO_DOMAIN:%1]
>
> This should work for port 80 as well.

No, because in general HTTP_HOST can be IP address, host name or FQDN and it won't work for second case ;)

Revision history for this message
Данило Шеган (danilo) wrote :

Can you give me an example where it won't work? I just wonder what is it that I am missing?

Revision history for this message
Georgy Redkozubov (gesha) wrote :

Use host name as 'host', i.e.:
   host = 'http://localhost'
but it will work with:
   host = 'http://localhost.localdomain' and host = 'http://127.0.0.1'

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.htaccess'
--- .htaccess 2011-12-19 16:57:20 +0000
+++ .htaccess 2012-01-13 12:13:26 +0000
@@ -3,6 +3,16 @@
33
4RewriteEngine On4RewriteEngine On
55
6## CO_DOMAIN is set to host name or host address
7## without port number for use in cookie domain
8RewriteCond %{SERVER_PORT} !^80$
9RewriteCond %{HTTP_HOST} (.*)(\:.*)
10RewriteRule .* - [E=CO_DOMAIN:%1]
11
12RewriteCond %{SERVER_PORT} ^80$
13RewriteCond %{HTTP_HOST} (^.*$)
14RewriteRule .* - [E=CO_DOMAIN:%1]
15
6## Let internal hosts through always.16## Let internal hosts through always.
7# android-build.linaro.org.17# android-build.linaro.org.
8RewriteCond %{REMOTE_ADDR} 50.17.250.69 [OR]18RewriteCond %{REMOTE_ADDR} 50.17.250.69 [OR]
@@ -45,11 +55,11 @@
45# Samsung.55# Samsung.
46RewriteCond %{REQUEST_URI} licenses/samsung-accepted.html$56RewriteCond %{REQUEST_URI} licenses/samsung-accepted.html$
47RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)57RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
48RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{HTTP_HOST}:5:%1,R,L]58RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:5:%1,R,L]
49# ST-E.59# ST-E.
50RewriteCond %{REQUEST_URI} licenses/ste-accepted.html$60RewriteCond %{REQUEST_URI} licenses/ste-accepted.html$
51RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)61RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
52RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{HTTP_HOST}:60:%1,R,L]62RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:60:%1,R,L]
5363
54## When license is being declined, show the notice that you have to accept it.64## When license is being declined, show the notice that you have to accept it.
55# Samsung.65# Samsung.
@@ -69,7 +79,7 @@
69## Redirect to the license file protected builds.79## Redirect to the license file protected builds.
70# Samsung.80# Samsung.
71RewriteCond %{REQUEST_URI} ^/.*origen.*$81RewriteCond %{REQUEST_URI} ^/.*origen.*$
72RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]82RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]
73# ST-E.83# ST-E.
74RewriteCond %{REQUEST_URI} ^/.*snowball.*84RewriteCond %{REQUEST_URI} ^/.*snowball.*
75RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]85RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]

Subscribers

People subscribed via source and target branches