ehttprequest Extension of the CHttpRequest class supporting location information and reverse proxy support.

  1. Requirements
  2. Usage
  3. Resources

We are using Amazon Web Services (AWS) for hosting and load balancing (among others). When using load balancing or other types of reversed proxies, the request tends to originate from the load balancer or proxy instead of from the user itself. Therefore, some functions in CHttpRequest return information about the proxy or load balancer instead of the user.This class extends CHttpRequest for that purpose and provides user location information.

Requirements

This extension makes use of the EHttpClient (make sure you autoload the client or import the class before using this extension) and should run on Yii v1.1.5 till v1.1.9.

Usage

Once unpacked in extensions, the extension can be implemented and use like in this example.

Your configuration file:

...
'request' => array(
	'class' => 'application.extensions.EHttpRequest',
	'useReverseProxyHeaders'=>true, 
),
...

useReverseProxyHeaders tells whether to search for headers added by reverse proxies (e.g. load balancers).

Use of the extension:

$city = Yii::app()->request->userCity;
$countryCode = Yii::app()->request->userCountryCode;
$countryName = Yii::app()->request->userCountryName;
$hostAddress = Yii::app()->request->userHostAddress;
$isSecureConnection = Yii::app()->request->isSecureConnection;

Resources

This extension is on GitHub.

1 0
3 followers
0 downloads
Yii Version: Unknown
License: MIT
Category: Others
Developed by: Emile Bons
Created on: Jul 3, 2013
Last updated: 11 years ago

Related Extensions