Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP PUT does not honor request parameters #2035

Closed
asfimport opened this issue Oct 12, 2007 · 10 comments
Closed

HTTP PUT does not honor request parameters #2035

asfimport opened this issue Oct 12, 2007 · 10 comments

Comments

@asfimport
Copy link
Collaborator

Greg Smith (Bug 43612):
When using the HTTP PUT method on an HTTP Sampler, the request parameters are
not honored. If request parameters are specified, they are ignored and not
placed in the request.

The behavior of PUT should be similar to POST -- if request parameters are
specified, they should be included in the body of the request.

With new REST based applications, the use of the other HTTP verbs are much more
common, with PUT being a standard way to update data within REST a rest app.

Allowing PUT to work equivalent to POST (with request parameters and content
type) should be sufficient.

Severity: normal
OS: All

Duplicates:

@asfimport
Copy link
Collaborator Author

Alf Hogemark (migrated from Bugzilla):
I believe this is fixed in SVN changelist 584535, so you can do some testing.
But I will not mark this bug as fixed before I have added some unit tests for
this case.

@asfimport
Copy link
Collaborator Author

Greg Smith (migrated from Bugzilla):
Hi Alf,

I extracted the latest (SVN 584775) and I am still having the problem with the
latest version. To be more precise about my use case:

I have REST style app that uses JSON and HTTP verbs for all client interaction.
When I tried to use HTTP PUT, with Content Encoding of "application/json",
Method of "PUT", and added a request parameter with my JSON data (Value = empty,
Encode = not checked, Include Equals = not checked), I got the following as the
request:

PUT /resources/employees/user1 HTTP/1.1
Connection: keep-alive
X-lori-time-1: 1192051198765
Accept-Encoding: gzip,deflate
Referer: http://localhost:8080/
Cache-Control: no-cache
Accept-Charset: ISO-8859-1,utf-8;q=0.7,;q=0.7
Pragma: no-cache
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7)
Gecko/20070914 Firefox/2.0.0.7
Keep-Alive: 300
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,
/*;q=0.5
Host: localhost:8080
Accept-Language: en-us,en;q=0.5
Content-Type: application/json

With no body. (no content length, either)

The original sampler item was created through the HTTP Proxy Server. (which is
why it has all of the above headers)

By switching the same request to method = "POST", the JSON content from the
request parameter is available in the body.

I am happy to do any additional testing or help with debugging.
Thanks

@asfimport
Copy link
Collaborator Author

Alf Hogemark (migrated from Bugzilla):
(In reply to comment 2)
If you could attach the test plan (remove any usernames / passwords), that would
be great. Then I could use it for testing, just by changing the sampler
slightly, to point it to the "HTTP Mirror Server" of JMeter.

I think I'll manage to have a look at it tomorrow evening.

@asfimport
Copy link
Collaborator Author

Alf Hogemark (migrated from Bugzilla):
I managed to do some testing today.
Here it the test plan I use for testing, against the HTTP Mirror server.

Created attachment bug_43612.jmx: Tets plan with PUT requests using the two HTTP samplers

bug_43612.jmx
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="1.8">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments"/>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
        <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Løkke kontroller" enabled="true">
          <boolProp name="LoopController.continue_forever">false</boolProp>
          <stringProp name="LoopController.loops">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1192477280000</longProp>
        <longProp name="ThreadGroup.end_time">1192477280000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" testname="HTTP Request" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="" elementType="HTTPArgument">
                <boolProp name="HTTPArgument.always_encode">false</boolProp>
                <stringProp name="Argument.value">somejsonvalue</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
                <boolProp name="HTTPArgument.use_equals">true</boolProp>
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="HTTPSampler.domain">localhost</stringProp>
          <stringProp name="HTTPSampler.port">8080</stringProp>
          <stringProp name="HTTPSampler.protocol"></stringProp>
          <stringProp name="HTTPSampler.method">PUT</stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path">/resources/employees/user1</stringProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
          <stringProp name="HTTPSampler.mimetype">application/json</stringProp>
          <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
          <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
          <stringProp name="HTTPSampler.monitor">false</stringProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
        </HTTPSampler>
        <hashTree/>
        <HTTPSampler2 guiclass="HttpTestSampleGui2" testclass="HTTPSampler2" testname="HTTP Request HTTPClient" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
            <collectionProp name="Arguments.arguments">
              <elementProp name="" elementType="HTTPArgument">
                <boolProp name="HTTPArgument.always_encode">false</boolProp>
                <stringProp name="Argument.value">somejsonvalue</stringProp>
                <stringProp name="Argument.metadata">=</stringProp>
                <boolProp name="HTTPArgument.use_equals">true</boolProp>
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="HTTPSampler.domain">localhost</stringProp>
          <stringProp name="HTTPSampler.port">8080</stringProp>
          <stringProp name="HTTPSampler.protocol"></stringProp>
          <stringProp name="HTTPSampler.method">PUT</stringProp>
          <stringProp name="HTTPSampler.contentEncoding"></stringProp>
          <stringProp name="HTTPSampler.path">/resources/employees/user1</stringProp>
          <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
          <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
          <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
          <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
          <stringProp name="HTTPSampler.mimetype">application/json</stringProp>
          <stringProp name="HTTPSampler.FILE_NAME"></stringProp>
          <stringProp name="HTTPSampler.FILE_FIELD"></stringProp>
          <stringProp name="HTTPSampler.monitor">false</stringProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
        </HTTPSampler2>
        <hashTree/>
        <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
          <boolProp name="ResultCollector.error_logging">false</boolProp>
          <objProp>
            <value class="SampleSaveConfiguration">
              <time>true</time>
              <latency>true</latency>
              <timestamp>true</timestamp>
              <success>true</success>
              <label>true</label>
              <code>true</code>
              <message>true</message>
              <threadName>true</threadName>
              <dataType>true</dataType>
              <encoding>false</encoding>
              <assertions>true</assertions>
              <subresults>true</subresults>
              <responseData>false</responseData>
              <samplerData>false</samplerData>
              <xml>true</xml>
              <fieldNames>false</fieldNames>
              <responseHeaders>false</responseHeaders>
              <requestHeaders>false</requestHeaders>
              <responseDataOnError>false</responseDataOnError>
              <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
              <assertionsResultsToSave>0</assertionsResultsToSave>
              <bytes>true</bytes>
            </value>
            <name>saveConfig</name>
          </objProp>
          <stringProp name="filename"></stringProp>
        </ResultCollector>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

@asfimport
Copy link
Collaborator Author

Alf Hogemark (migrated from Bugzilla):
I think I have solved the problem now, you should try the SVN changelist 584882.
If you want to test that, it would be helpful.
I'll try to add unit tests for the code tomorrow, so that we can be more certain
that the code is correct.

@asfimport
Copy link
Collaborator Author

Greg Smith (migrated from Bugzilla):
Hi Alf,

I rebuilt with the latest, and my Test Plan with a PUT works now. That seemed
to do it

Thanks much,
Greg

@asfimport
Copy link
Collaborator Author

Alf Hogemark (migrated from Bugzilla):
Fixed in SVN changelist 585212.

@asfimport
Copy link
Collaborator Author

Artem Fedorov (migrated from Bugzilla):
Created attachment request.png: Put request with body

Put request with body

@asfimport
Copy link
Collaborator Author

Artem Fedorov (migrated from Bugzilla):
Created attachment result.png: Http Sampler without expected body

Http Sampler without expected body

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Fixed within #4735

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant