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

Add addHeader function for neko and php #9063

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions std/neko/Web.hx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ class Web {
_cgi_set_header(untyped h.__s, untyped v.__s);
}

/**
Add an output header value. If some data have been printed, the headers have
already been sent so this will raise an exception.
**/
public static function addHeader(h:String, v:String) {
_cgi_add_header(untyped h.__s, untyped v.__s);
}

/**
Set the HTTP return code. Same remark as setHeader.
**/
Expand Down Expand Up @@ -309,6 +317,7 @@ class Web {
static var _get_uri:Dynamic;
static var _cgi_redirect:Dynamic;
static var _cgi_set_header:Dynamic;
static var _cgi_add_header:Dynamic;
static var _set_return_code:Dynamic;
static var _get_client_header:Dynamic;
static var _get_params_string:Dynamic;
Expand Down Expand Up @@ -336,6 +345,7 @@ class Web {
_get_uri = Lib.load(lib, "get_uri", 0);
_cgi_redirect = Lib.load(lib, "redirect", 1);
_cgi_set_header = Lib.load(lib, "set_header", 2);
_cgi_add_header = Lib.load(lib, "add_header", 2);
_set_return_code = Lib.load(lib, "set_return_code", 1);
_get_client_header = Lib.load(lib, "get_client_header", 1);
_get_params_string = Lib.load(lib, "get_params_string", 0);
Expand Down Expand Up @@ -368,6 +378,7 @@ class Web {
Lib.print("Location: " + v + "\n");
};
_cgi_set_header = function(h, v) {};
_cgi_add_header = function(h, v) {};
_set_return_code = function(i) {};
_get_client_header = function(h) {
return null;
Expand Down
8 changes: 8 additions & 0 deletions std/php/Web.hx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ class Web {
header('$h: $v');
}

/**
Add an output header value. If some data have been printed, the headers have
already been sent so this will raise an exception.
**/
public static inline function addHeader(h:String, v:String) {
header('$h: $v', false);
}

/**
Set the HTTP return code. Same remark as `php.Web.setHeader()`.
See status code explanation here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Expand Down