Skip to content

Commit

Permalink
CXF-8894: Unimplemented getRequestCharacterEncoding() (apache#1441)
Browse files Browse the repository at this point in the history
  • Loading branch information
reta authored Oct 5, 2023
1 parent 1d8b2be commit 1a02ba3
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public JettyHTTPHandler(JettyHTTPDestination jhd, boolean cmExact) {
contextMatchExact = cmExact;
jettyHTTPDestination = jhd;
}

public JettyHTTPHandler(Bus bus) {
this.bus = bus;
}
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ public synchronized void addServant(URL url, JettyHTTPHandler handler) {
}

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
Expand Down

0 comments on commit 1a02ba3

Please sign in to comment.