Skip to content

Commit 204d3ee

Browse files
committed
header() function behavior
- do not report warning on console app
1 parent 26ec71b commit 204d3ee

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Peachpie.Library/Web.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,23 @@ static bool TryMatchHttpStatusHeader(ReadOnlySpan<char> header, out int code)
514514
/// </remarks>
515515
public static void header(Context ctx, string str, bool replace = true, int http_response_code = 0)
516516
{
517+
if (string.IsNullOrEmpty(str))
518+
{
519+
// empty arg, ignore
520+
//PhpException.InvalidArgument(nameof(str));
521+
return;
522+
}
523+
517524
var webctx = ctx.HttpPhpContext;
518-
if (webctx == null || string.IsNullOrEmpty(str) || webctx.HeadersSent)
525+
if (webctx == null)
526+
{
527+
// ignore on console app
528+
return;
529+
}
530+
531+
if (webctx.HeadersSent)
519532
{
533+
// header sent
520534
PhpException.Throw(PhpError.Notice, Resources.Resources.headers_has_been_sent);
521535
return;
522536
}

0 commit comments

Comments
 (0)