Login | Register
My pages Projects Community openCollabNet

Discussions > dev > [maxq-dev] some questions and updates suggestions about the AbstractCodeGenerator

maxq
Discussion topic

Back to topic list

[maxq-dev] some questions and updates suggestions about the AbstractCodeGenerator

Author dillense
Full name Bruno Dillenseger
Date 2012-04-05 01:52:38 PDT
Message <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hello all,<br>
    <br>
    I'm currently working on a MaxQ update in order to improve the HTTP
    capture tool for the CLIF load testing tool (<a
      href="http://clif.ow2.org">clif.ow2.org​</a>).<br>
    I have some remarks, questions and suggestions. All of them are
    related to the com.bitmechanic.maxq​.generator.AbstractC​odeGenerator
    class.<br>
    <br>
    First, the latest version of MaxQ seems unable to capture SOAP
    requests and GWT requests (for example) sent through the POST
    method. The reason for this is that MaxQ always handles the body of
    POST requests as a form submission, i.e. key-value pairs. As far as
    I understand from the HTTP protocol, this should only occur when the
    content-type header specifies an "application/x-www-f​orm-urlencoded"
    MIME-type. When it is not the case, I would suggest to just get the
    body's bytes and to call the doSetData() with the String resulting
    from these bytes as argument. Currently, the doSetData() method is
    used only for multipart posts. What do you think about the impact on
    "real" code generators (other than ISAC code generator, since I know
    it very well)?<br>
    <br>
    Then, as far as I understand, when converting the body's bytes into
    a String, we must take care of the character encoding specified by
    the charset attribute of the content-type header. What is currently
    strange is that:<br>
    <ul>
      <li>the "charset" attribute is never set</li>
      <li>the value of variable "newCharset" turns to be ";
        charset=xxx", while I would expect "xxx"</li>
    </ul>
    I don't know what to do with the "charset" attribute, but for the
    newCharset variable, I suggest this piece of code to actually get
    the charset name (based on the JDK's java.util.regex package):<br>
    <blockquote>​<tt>String newCharset = null;</tt><br>
      <tt>Matcher charsetParser =
Pattern.compile("cha​rset=([a-zA-Z0-9_\​-]+)").matcher(head​er.contentType);<​/tt><br>
      <tt>if (charsetParser.matches()) {</tt><br>
      <tt>&nbsp; newCharset = charsetParser.group(​);</tt><br​>
      <tt>&nbsp; </tt><tt​>doSetCharset(newCha​rset);</tt>​<br>
      <tt>}</tt​><br>
    </blockquote>
    Finally, going back to the POST body management, I suggest the
    following:<br>
    <blockquote>​<tt>boolean isFormRequest =
        header.contentType.s​tartsWith("applicati​on/x-www-form-urlenc​oded");</tt>​<br>
      <br>
      <tt>if (requestBody.length &gt; 0) {<br>
        &nbsp; if (isMultiPartRequest) {<br>
        &nbsp;&nbsp;&nbsp; // Update the action with the mutipart data.<br>
        &nbsp;&nbsp;&nbsp; setMultiPartData(action, header, requestBody);<br>
        &nbsp; } else if (! isFormRequest) {<br>
        &nbsp;&nbsp;&nbsp; if (newCharset != null) {<br>
        &nbsp;&nbsp;​&nbsp;&nbsp;​&nbsp; doSetData(new String(requestBody, newCharset));<br>
        &nbsp;&nbsp;&nbsp; } else {<br>
        &nbsp;&nbsp;​&nbsp;&nbsp;​&nbsp; doSetData(new String(requestBody));<br>
        &nbsp;&nbsp;&nbsp; }<br>
        &nbsp; } else {<br>
      </tt><tt​>&nbsp;&nbsp​;&nbsp; if (newCharset != null) {<br>
        &nbsp;&nbsp;​&nbsp;&nbsp;​&nbsp; </tt><tt​>setBodyParams</t​t><tt>(acti​on, new
        String(requestBody, newCharset));<br>
        &nbsp;&nbsp;&nbsp; } else {<br>
        &nbsp;&nbsp;​&nbsp;&nbsp;​&nbsp; </tt><tt​>setBodyParams</t​t><tt>(acti​on, new
        String(requestBody));<br>
        &nbsp;&nbsp;&nbsp; }</tt><tt​><br>
        &nbsp; }<br>
        }<br>
      </tt></blockquote>
    What do you think?<br>
    <br>
    Best regards,<br>
    <div class="moz-signature">-- Bruno.<br>
      <title>Votre signature email Orange (en France)</title>
      <p style="font-family: Arial,Helvetica,sans-serif; margin-top:
        10pt; margin-bottom: 10pt; font-size: 10pt; color: rgb(0, 0,
        0);"><img src="cid:part1.01060​906.05060907@orange.​com"
          height="40" width="40"></p>
      <p style="font-family: Arial,Helvetica,sans-serif; margin-top:
        0pt; margin-bottom: 0pt; font-size: 10pt; color: rgb(0, 0, 0);">
        <b>Bruno Dillenseger</b><br>
        distributed systems research engineer<a
          href="mailto:bruno.d​illenseger at orange dot co​m" style="font-family:
          Arial,Helvetica,sans-serif; font-size: 10pt; color: rgb(255,
          102, 0);"><br>
        </a></p>
    </div>
  </body>
</html>
Attachments

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

[maxq-dev] some questions and updates suggestions about the AbstractCodeGenerator dillense Bruno Dillenseger 2012-04-05 01:52:38 PDT
Messages per page: