Skip to content

Commit

Permalink
merge: header, PhpStackTrace
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed Nov 16, 2022
1 parent 9d72b9e commit b5dad20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/Peachpie.Library/Web.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,23 @@ static bool TryMatchHttpStatusHeader(ReadOnlySpan<char> header, out int code)
/// </remarks>
public static void header(Context ctx, string str, bool replace = true, int http_response_code = 0)
{
if (string.IsNullOrEmpty(str))
{
// empty arg, ignore
//PhpException.InvalidArgument(nameof(str));
return;
}

var webctx = ctx.HttpPhpContext;
if (webctx == null || string.IsNullOrEmpty(str) || webctx.HeadersSent)
if (webctx == null)
{
// ignore on console app
return;
}

if (webctx.HeadersSent)
{
// header sent
PhpException.Throw(PhpError.Notice, Resources.Resources.headers_has_been_sent);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Peachpie.Runtime/Reflection/PhpStackTrace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ public string TypeName

if (tinfo.IsPublic && tinfo.IsAbstract) // => public static
{
if (tinfo.Assembly.IsDefined(typeof(PhpExtensionAttribute)))
var extensionAttrs = Attribute.GetCustomAttributes(tinfo.Assembly, typeof(PhpExtensionAttribute));
if (extensionAttrs != null && extensionAttrs.Length != 0)
{
// library function
return null;
Expand Down

0 comments on commit b5dad20

Please sign in to comment.