From 176e46912a80e8d11aa7c15ade1513df733bf248 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Wed, 20 Sep 2023 20:03:03 -0400 Subject: [PATCH] CXF-8894: Unimplemented getRequestCharacterEncoding() - use org.eclipse.jetty.servlet.ServletContextHandler --- .../http_jetty/JettyContextHandler.java | 62 +++++++++++++++++++ .../http_jetty/JettyHTTPHandler.java | 3 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextHandler.java diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextHandler.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextHandler.java new file mode 100644 index 00000000000..94e96bce859 --- /dev/null +++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyContextHandler.java @@ -0,0 +1,62 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.transport.http_jetty; + +import org.eclipse.jetty.server.handler.ContextHandler; + +/** + * The Jetty-specific ContextHandler + */ +class JettyContextHandler extends ContextHandler { + JettyContextHandler() { + super(null, null, null); + _scontext = new JettyContext(); + } + + class JettyContext extends Context { + @Override + public String getRequestCharacterEncoding() { + return getDefaultRequestCharacterEncoding(); + } + + @Override + public void setRequestCharacterEncoding(String encoding) { + if (!isStarting()) { + throw new IllegalStateException(); + } + + setDefaultRequestCharacterEncoding(encoding); + } + + @Override + public String getResponseCharacterEncoding() { + return getDefaultResponseCharacterEncoding(); + } + + @Override + public void setResponseCharacterEncoding(String encoding) { + if (!isStarting()) { + throw new IllegalStateException(); + } + + setDefaultResponseCharacterEncoding(encoding); + } + } +} diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java index e4f54d08e07..2be0114cc1c 100644 --- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java +++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPHandler.java @@ -43,6 +43,7 @@ public JettyHTTPHandler(JettyHTTPDestination jhd, boolean cmExact) { contextMatchExact = cmExact; jettyHTTPDestination = jhd; } + public JettyHTTPHandler(Bus bus) { this.bus = bus; } @@ -84,7 +85,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques } public ContextHandler createContextHandler() { - return new ContextHandler(); + return new JettyContextHandler(); } public Bus getBus() {