#697 Ignore errors when resolving variables in CONTENT option

Next
closed-fixed
5
2011-10-20
2011-10-20
No

The CONTENT option for the HTTP service's DOPOST and REQUEST METHOD requests resolves STAF variables. However, the content can contain one or more { characters that do not denote a STAF variable. For example: {"greetings":"Hello, World!"}
However, currently that will result in a variable resolution error since it thinks the { denotes a STAF variable (when it does not). It would be better if the HTTP service used the IGNOREERRORS option when submitting a VAR RESOLVE request to resolve STAF variables in the CONTENT option's value so that you don't have to escape the { with a caret (^), e.g. ^{"greetings":"Hello, World!"} in order to avoid a variable resolution error.

This issue was encountered and described in the STAF Help forum posting at https://sourceforge.net/projects/staf/forums/forum/104046/topic/4769093.

Note that as support for the IGNOREERRORS option was added in STAF V3.4.0, the HTTP service will now require STAF V3.4.0 or later (instead of STAF V3.1.0 or later).

Discussion

  • Sharon Lucas

    Sharon Lucas - 2011-10-20
    • status: open --> closed-fixed
     
  • Sharon Lucas

    Sharon Lucas - 2011-10-20

    Here's a cvs diff of the changes:

    Index: HTTP.java

    RCS file: /cvsroot/staf/src/staf/services/http/HTTP.java,v
    retrieving revision 1.59
    diff -r1.59 HTTP.java
    84c84
    < private static final String VERSIONINFO = "3.0.3";
    ---
    > private static final String VERSIONINFO = "3.0.4";
    89c89
    < private static final String REQUIREDSTAFVERSION = "3.1.0";
    ---
    > private static final String REQUIREDSTAFVERSION = "3.4.0";
    1635c1635,1638
    < res = STAFUtil.resolveRequestVar(
    ---
    > // Ignore any errors resolving variables in the CONTENT option's value
    > // as it could contain "{" characters that don't denote STAF variables
    >
    > res = resolveRequestVarIgnoreErrors(
    3334a3338,3373
    > /***********************************************************************/
    > /* Description: */
    > /* This method resolves any STAF variables that are contained within */
    > /* the string passed in by submitting a */
    > /* RESOLVE REQUEST <request#> STRING <value> IGNOREERRORS */
    > /* request to the VAR service on the local system. */
    > /* Note: Can't use STAFUtil.resolveRequestVar() method because it */
    > /* doesn't support specifying the IGNOREERRORS option for a */
    > /* VAR RESOLVE request. */
    > /* */
    > /* Input: String that may contain STAF variables to be resolved */
    > /* STAF handle */
    > /* Request number */
    > /* */
    > /* Returns: */
    > /* STAFResult.rc = the return code (STAFResult.Ok if successful) */
    > /* STAFResult.result = the resolved value if successful */
    > /* an error message if not successful */
    > /***********************************************************************/
    > private static STAFResult resolveRequestVarIgnoreErrors(
    > String value, STAFHandle handle, int requestNumber)
    > {
    > if (value.indexOf("{") != -1)
    > {
    > // The string may contains STAF variables
    >
    > STAFResult resolvedResult = handle.submit2(
    > "local", "VAR", "RESOLVE REQUEST " + requestNumber +
    > " STRING " + STAFUtil.wrapData(value) + " IGNOREERRORS");
    >
    > return resolvedResult;
    > }
    >
    > return new STAFResult(STAFResult.Ok, value);
    > }
    >
    Index: Http.html
    ===================================================================
    RCS file: /cvsroot/staf/src/staf/services/http/Http.html,v
    retrieving revision 1.50
    diff -r1.50 Http.html
    124c124
    < <LI>STAF 3.1.0 or later</LI>
    ---
    > <LI>STAF 3.4.0 or later</LI>
    828c828,830
    < methods. This parameter is optional. This option will resolve variables.</P>
    ---
    > methods. This parameter is optional.
    > This option will resolve variables using the IGNOREERRORS option when submitting
    > a VAR RESOLVE request.</P>

     
  • Sharon Lucas

    Sharon Lucas - 2011-10-20

    This feature will be in HTTP V3.0.4.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks