You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2020/04/01 03:56:01 UTC

[wicket] branch master updated: Check whether the WebResponse supports headers before trying to write such

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/master by this push:
     new 6840161  Check whether the WebResponse supports headers before trying to write such
6840161 is described below

commit 68401610e388b9d751c8940fef2628cd1c9d82fd
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Wed Apr 1 06:54:38 2020 +0300

    Check whether the WebResponse supports headers before trying to write such
    
    Currently the WebSocket examples throw an exception
---
 .../org/apache/wicket/examples/WicketExampleApplication.java     | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleApplication.java
index 2303b34..aa083c3 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleApplication.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExampleApplication.java
@@ -73,9 +73,12 @@ public abstract class WicketExampleApplication extends WebApplication
 			@Override
 			public void onEndRequest(RequestCycle cycle)
 			{
-				((WebResponse) cycle.getResponse()).addHeader("Server-Timing",
-					"server;desc=\"Wicket rendering time\";dur="
-						+ (System.currentTimeMillis() - cycle.getStartTime()));
+				final WebResponse webResponse = (WebResponse) cycle.getResponse();
+				if (webResponse.isHeaderSupported())
+				{
+					final long serverTime = System.currentTimeMillis() - cycle.getStartTime();
+					webResponse.addHeader("Server-Timing", "server;desc=\"Wicket rendering time\";dur=" + serverTime);
+				}
 			}
 		});
 	}