Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$_SERVER['SERVER_PORT'] isn't available in Google App Engine #962

Closed
german-chosen opened this issue Dec 15, 2014 · 5 comments
Closed

$_SERVER['SERVER_PORT'] isn't available in Google App Engine #962

german-chosen opened this issue Dec 15, 2014 · 5 comments

Comments

@german-chosen
Copy link

This the message I get:

Notice: Undefined index: SERVER_PORT in /base/data/home/apps/s~myapp/.../vendor/slim/slim/Slim/Environment.php on line 154

My solution was defining (in the beginning of the index.php file):

$_SERVER['SERVER_PORT'] = 80;

@diegoluisr
Copy link

I have this problem too, i hack que line
$env['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
from slim/Environment.php
and i change this life for
$env['SERVER_PORT'] = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;

This Problem was reported in 2010, without Google solution.
https://code.google.com/p/googleappengine/issues/detail?id=2818

@codeguy
Copy link
Member

codeguy commented Jan 27, 2015

Thanks. I'll add a default value of 80 if this value is not available. Do you want to submit a PR to the develop branch?

@tassoevan
Copy link

What about get the value from $_SERVER["HTTP_HOST"]? I don't know if it's a safe method to get this information (according to the PHP docs, even $_SERVER["SERVER_PORT"] isn't), but does the trick.

@msjyoo
Copy link
Contributor

msjyoo commented Feb 26, 2015

Pull Request #1025 #1026 created that fixes this issue from both the master and develop branches.

codeguy added a commit that referenced this issue Feb 27, 2015
Fixes #962, Missing SERVER_PORT on GAE. For branch master.
codeguy added a commit that referenced this issue Feb 27, 2015
Fixes #962, Missing SERVER_PORT on GAE. For branch develop.
moffe42 pushed a commit to ColourboxDevelopment/Slim that referenced this issue Sep 7, 2015
* upstream/2.x: (33 commits)
  Updated version number references for upcoming Slim 2.6.3
  Clean up the output buffon on error in debug mode
  Updated version number references for Slim 2
  Updated the other code snippets as well
  Added color to the Readme
  Update How to Contribute section of README
  fixed broken license link
  Update SessionCookie unit tests for new JSON decoding
  Fix the build indicator.
  escape html code in exception page
  update version number in tests folder
  update version numbers
  Fix slimphp#1034 (CVE-2015-2171)
  Correct terminology in README
  travis: PHP 7.0 nightly added
  Fixes slimphp#962, Missing SERVER_PORT on GAE.
  Add HTTP status codes from new RFCs.
  Update index.php to fix broken "Hello World" link
  Fix: Method doesn't return anything
  Fix: Undefined classes
  ...
@garnold
Copy link

garnold commented Feb 8, 2017

@codeguy Reopening an oldie but goodie as I just bumped into this issue. App Engine supports HTTP and HTTPS, so defaulting to 80 doesn't always work. A more reliable way to set the default value is to consult $_SERVER['HTTPS']:

if (!isset($_SERVER['SERVER_PORT'])) {
     $_SERVER['SERVER_PORT'] = $_SERVER['HTTPS'] == 'off' ? 80 : 443;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants