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
1=== modified file '.htaccess'
2--- .htaccess 2011-12-19 16:57:20 +0000
3+++ .htaccess 2012-01-13 12:13:26 +0000
4@@ -3,6 +3,16 @@
5
6 RewriteEngine On
7
8+## CO_DOMAIN is set to host name or host address
9+## without port number for use in cookie domain
10+RewriteCond %{SERVER_PORT} !^80$
11+RewriteCond %{HTTP_HOST} (.*)(\:.*)
12+RewriteRule .* - [E=CO_DOMAIN:%1]
13+
14+RewriteCond %{SERVER_PORT} ^80$
15+RewriteCond %{HTTP_HOST} (^.*$)
16+RewriteRule .* - [E=CO_DOMAIN:%1]
17+
18 ## Let internal hosts through always.
19 # android-build.linaro.org.
20 RewriteCond %{REMOTE_ADDR} 50.17.250.69 [OR]
21@@ -45,11 +55,11 @@
22 # Samsung.
23 RewriteCond %{REQUEST_URI} licenses/samsung-accepted.html$
24 RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
25-RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{HTTP_HOST}:5:%1,R,L]
26+RewriteRule .* %1%2 [CO=samsunglicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:5:%1,R,L]
27 # ST-E.
28 RewriteCond %{REQUEST_URI} licenses/ste-accepted.html$
29 RewriteCond %{HTTP_COOKIE} downloadrequested=([^\;]*\/)([^/\;]*)
30-RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{HTTP_HOST}:60:%1,R,L]
31+RewriteRule .* %1%2 [CO=stelicenseaccepted-v1:true:.%{ENV:CO_DOMAIN}:60:%1,R,L]
32
33 ## When license is being declined, show the notice that you have to accept it.
34 # Samsung.
35@@ -69,7 +79,7 @@
36 ## Redirect to the license file protected builds.
37 # Samsung.
38 RewriteCond %{REQUEST_URI} ^/.*origen.*$
39-RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]
40+RewriteRule .* /licenses/samsung-v2.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]
41 # ST-E.
42 RewriteCond %{REQUEST_URI} ^/.*snowball.*
43-RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{HTTP_HOST},R,L]
44+RewriteRule .* /licenses/ste.html [CO=downloadrequested:%{REQUEST_URI}:.%{ENV:CO_DOMAIN},R,L]

Subscribers

People subscribed via source and target branches