(PROTO)
| 16574 | } |
| 16575 | |
| 16576 | function extend_request(PROTO) { |
| 16577 | |
| 16578 | PROTOREQ = PROTO; |
| 16579 | |
| 16580 | Object.defineProperty(PROTO, 'ip', { |
| 16581 | get: function() { |
| 16582 | if (this._ip) |
| 16583 | return this._ip; |
| 16584 | |
| 16585 | // x-forwarded-for: client, proxy1, proxy2, ... |
| 16586 | var proxy = this.headers['x-forwarded-for']; |
| 16587 | if (proxy) |
| 16588 | this._ip = proxy.split(',', 1)[0] || this.connection.remoteAddress; |
| 16589 | else if (!this._ip) |
| 16590 | this._ip = this.connection.remoteAddress; |
| 16591 | |
| 16592 | return this._ip; |
| 16593 | } |
| 16594 | }); |
| 16595 | |
| 16596 | Object.defineProperty(PROTO, 'query', { |
| 16597 | get: function() { |
| 16598 | !this._querydata && F.$onParseQueryUrl(this); |
| 16599 | return this._querydata; |
| 16600 | }, |
| 16601 | set: function(value) { |
| 16602 | this._querydata = value; |
| 16603 | } |
| 16604 | }); |
| 16605 | |
| 16606 | Object.defineProperty(PROTO, 'subdomain', { |
| 16607 | get: function() { |
| 16608 | if (this._subdomain) |
| 16609 | return this._subdomain; |
| 16610 | var subdomain = this.uri.hostname.toLowerCase().replace(REG_WWW, '').split('.'); |
| 16611 | if (subdomain.length > 2) // example: [subdomain].domain.com |
| 16612 | this._subdomain = subdomain.slice(0, subdomain.length - 2); |
| 16613 | else if (subdomain.length > 1 && subdomain[subdomain.length - 1] === 'localhost') // example: [subdomain].localhost |
| 16614 | this._subdomain = subdomain.slice(0, subdomain.length - 1); |
| 16615 | else |
| 16616 | this._subdomain = null; |
| 16617 | return this._subdomain; |
| 16618 | } |
| 16619 | }); |
| 16620 | |
| 16621 | Object.defineProperty(PROTO, 'host', { |
| 16622 | get: function() { |
| 16623 | return this.headers['host']; |
| 16624 | } |
| 16625 | }); |
| 16626 | |
| 16627 | Object.defineProperty(PROTO, 'split', { |
| 16628 | get: function() { |
| 16629 | return this.$path ? this.$path : this.$path = framework_internal.routeSplit(this.uri.pathname, true); |
| 16630 | } |
| 16631 | }); |
| 16632 | |
| 16633 | Object.defineProperty(PROTO, 'secured', { |
no test coverage detected