This is an automated email from the ASF dual-hosted git repository. reta pushed a commit to branch 3.6.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.6.x-fixes by this push: new e35f359699 CXF-8894: Unimplemented getRequestCharacterEncoding() (#1441) e35f359699 is described below commit e35f359699a87e41bc9287d761a82a042d342dc3 Author: Andriy Redko <drr...@gmail.com> AuthorDate: Thu Oct 5 09:33:18 2023 -0400 CXF-8894: Unimplemented getRequestCharacterEncoding() (#1441) (cherry picked from commit 1a02ba3850ca6930e318c65b64e028385514e34a) --- .../transport/http_jetty/JettyContextHandler.java | 62 ++++++++++++++++++++++ .../cxf/transport/http_jetty/JettyHTTPHandler.java | 3 +- .../http_jetty/JettyHTTPServerEngine.java | 3 ++ 3 files changed, 67 insertions(+), 1 deletion(-) 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 0000000000..94e96bce85 --- /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 b35b7f9d86..1fa6bd3f72 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 @@ -44,6 +44,7 @@ public class JettyHTTPHandler extends AbstractHandler { contextMatchExact = cmExact; jettyHTTPDestination = jhd; } + public JettyHTTPHandler(Bus bus) { this.bus = bus; } @@ -85,7 +86,7 @@ public class JettyHTTPHandler extends AbstractHandler { } public ContextHandler createContextHandler() { - return new ContextHandler(); + return new JettyContextHandler(); } public Bus getBus() { diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java index 201706ceb9..fec87cb311 100644 --- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java +++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java @@ -491,6 +491,9 @@ public class JettyHTTPServerEngine implements ServerEngine, HttpServerEngineSupp } String contextName = HttpUriMapper.getContextName(url.getPath()); + if (contextName.isEmpty()) { + contextName = "/"; + } ContextHandler context = handler.createContextHandler(); context.setContextPath(contextName); // bind the jetty http handler with the context handler