View | Details | Raw Unified | Return to bug 48692
Collapse All | Expand All

(-)java/org/apache/catalina/connector/LocalStrings.properties (+1 lines)
Lines 30-35 Link Here
30
coyoteConnector.protocolHandlerResumeFailed=Protocol handler resume failed
30
coyoteConnector.protocolHandlerResumeFailed=Protocol handler resume failed
31
coyoteConnector.MapperRegistration=register Mapper: {0}
31
coyoteConnector.MapperRegistration=register Mapper: {0}
32
coyoteConnector.protocolUnregistrationFailed=Protocol handler stop failed
32
coyoteConnector.protocolUnregistrationFailed=Protocol handler stop failed
33
coyoteConnector.parseBodyMethodNoTrace=TRACE method MUST NOT include an entity (see RFC 2616 Section 9.6)
33
34
34
#
35
#
35
# CoyoteAdapter
36
# CoyoteAdapter
(-)java/org/apache/catalina/connector/Request.java (-1 / +1 lines)
Lines 2596-2602 Link Here
2596
        if (usingInputStream || usingReader)
2596
        if (usingInputStream || usingReader)
2597
            return;
2597
            return;
2598
2598
2599
        if (!getMethod().equalsIgnoreCase("POST"))
2599
        if( !getConnector().isParseBodyMethod(getMethod()) )
2600
            return;
2600
            return;
2601
2601
2602
        String contentType = getContentType();
2602
        String contentType = getContentType();
(-)java/org/apache/catalina/connector/Connector.java (-1 / +46 lines)
Lines 18-24 Link Here
18
18
19
package org.apache.catalina.connector;
19
package org.apache.catalina.connector;
20
20
21
import java.util.Arrays;
21
import java.util.HashMap;
22
import java.util.HashMap;
23
import java.util.HashSet;
24
import java.util.Set;
22
25
23
import javax.management.MBeanRegistration;
26
import javax.management.MBeanRegistration;
24
import javax.management.MBeanServer;
27
import javax.management.MBeanServer;
Lines 44-50 Link Here
44
47
45
48
46
/**
49
/**
47
 * Implementation of a Coyote connector for Tomcat 5.x.
50
 * Implementation of a Coyote connector.
48
 *
51
 *
49
 * @author Craig R. McClanahan
52
 * @author Craig R. McClanahan
50
 * @author Remy Maucherat
53
 * @author Remy Maucherat
Lines 211-218 Link Here
211
     */
214
     */
212
    protected int maxSavePostSize = 4 * 1024;
215
    protected int maxSavePostSize = 4 * 1024;
213
216
217
    /**
218
     * Comma-separated list of HTTP methods that will be parsed according
219
     * to POST-style rules for application/x-www-form-urlencoded request bodies.
220
     */
221
    protected String parseBodyMethods = "POST";
214
222
215
    /**
223
    /**
224
     * A Set of methods determined by {@link #parseBodyMethods}.
225
     */
226
    protected Set<String> parseBodyMethodsSet;
227
228
229
    /**
216
     * Has this component been initialized yet?
230
     * Has this component been initialized yet?
217
     */
231
     */
218
    protected boolean initialized = false;
232
    protected boolean initialized = false;
Lines 617-622 Link Here
617
    }
631
    }
618
632
619
633
634
    public String getParseBodyMethods() {
635
636
        return this.parseBodyMethods;
637
638
    }
639
640
    public void setParseBodyMethods(String methods) {
641
642
        HashSet<String> methodSet = new HashSet<String>();
643
644
        if( null != methods )
645
            methodSet.addAll(Arrays.asList(methods.split("\\s*,\\s*")));
646
647
        if( methodSet.contains("TRACE") )
648
            throw new IllegalArgumentException(sm.getString("coyoteConnector.parseBodyMethodNoTrace"));
649
650
        this.parseBodyMethods = methods;
651
        this.parseBodyMethodsSet = methodSet;
652
653
    }
654
655
    protected boolean isParseBodyMethod(String method) {
656
657
        return parseBodyMethodsSet.contains(method);
658
659
    }
660
620
    /**
661
    /**
621
     * Return the port number on which we listen for requests.
662
     * Return the port number on which we listen for requests.
622
     */
663
     */
Lines 1071-1076 Link Here
1071
        adapter = new CoyoteAdapter(this);
1112
        adapter = new CoyoteAdapter(this);
1072
        protocolHandler.setAdapter(adapter);
1113
        protocolHandler.setAdapter(adapter);
1073
1114
1115
        // Make sure parseBodyMethodsSet has a default
1116
        if( null == parseBodyMethodsSet )
1117
            setParseBodyMethods(getParseBodyMethods());
1118
1074
        IntrospectionUtils.setProperty(protocolHandler, "jkHome",
1119
        IntrospectionUtils.setProperty(protocolHandler, "jkHome",
1075
                                       System.getProperty("catalina.base"));
1120
                                       System.getProperty("catalina.base"));
1076
1121
(-)webapps/docs/changelog.xml (+4 lines)
Lines 46-51 Link Here
46
<section name="Tomcat 6.0.36 (jfclere)" rtext="">
46
<section name="Tomcat 6.0.36 (jfclere)" rtext="">
47
  <subsection name="Catalina">
47
  <subsection name="Catalina">
48
    <changelog>
48
    <changelog>
49
      <update>
50
        <bug>48692</bug>: Provide option to parse
51
        <code>application/x-www-form-urlencoded</code> PUT requests. (schultz)
52
      </update>
49
      <add>
53
      <add>
50
        <bug>50306</bug>: New StuckThreadDetectionValve to detect requests that
54
        <bug>50306</bug>: New StuckThreadDetectionValve to detect requests that
51
        take a long time to process, which might indicate that their processing
55
        take a long time to process, which might indicate that their processing
(-)webapps/docs/config/ajp.xml (+20 lines)
Lines 130-135 Link Here
130
      to 4096 (4 kilobytes).</p>
130
      to 4096 (4 kilobytes).</p>
131
    </attribute>
131
    </attribute>
132
132
133
    <attribute name="parseBodyMethods" required="false">
134
      <p>A comma-separated list of HTTP methods for which request
135
      bodies will be parsed for request parameters identically
136
      to POST. This is useful in RESTful applications that want to
137
      support POST-style semantics for PUT requests.
138
      Note that any setting other than <code>POST</code> causes Tomcat
139
      to behave in a way that does against the intent of the servlet
140
      specification.
141
      The HTTP method TRACE is specifically forbidden here in accordance
142
      with the HTTP specification.
143
      The default is <code>POST</code></p>
144
    </attribute>
145
146
    <attribute name="port" required="true">
147
      <p>The TCP port number on which this <strong>Connector</strong>
148
      will create a server socket and await incoming connections.  Your
149
      operating system will allow only one server application to listen
150
      to a particular port number on a particular IP address.</p>
151
    </attribute>
152
133
    <attribute name="protocol" required="false">
153
    <attribute name="protocol" required="false">
134
      <p>Sets the protocol to handle incoming traffic. The default value is
154
      <p>Sets the protocol to handle incoming traffic. The default value is
135
        <code>AJP/1.3</code> and configures
155
        <code>AJP/1.3</code> and configures
(-)webapps/docs/config/http.xml (+20 lines)
Lines 137-142 Link Here
137
      to 4096 (4 kilobytes).</p>
137
      to 4096 (4 kilobytes).</p>
138
    </attribute>
138
    </attribute>
139
139
140
    <attribute name="parseBodyMethods" required="false">
141
      <p>A comma-separated list of HTTP methods for which request
142
      bodies will be parsed for request parameters identically
143
      to POST. This is useful in RESTful applications that want to
144
      support POST-style semantics for PUT requests.
145
      Note that any setting other than <code>POST</code> causes Tomcat
146
      to behave in a way that does against the intent of the servlet
147
      specification.
148
      The HTTP method TRACE is specifically forbidden here in accordance
149
      with the HTTP specification.
150
      The default is <code>POST</code></p>
151
    </attribute>
152
153
    <attribute name="port" required="true">
154
      <p>The TCP port number on which this <strong>Connector</strong>
155
      will create a server socket and await incoming connections.  Your
156
      operating system will allow only one server application to listen
157
      to a particular port number on a particular IP address.</p>
158
    </attribute>
159
140
    <attribute name="protocol" required="false">
160
    <attribute name="protocol" required="false">
141
      <p>
161
      <p>
142
        Sets the protocol to handle incoming traffic.
162
        Sets the protocol to handle incoming traffic.

Return to bug 48692