Sharmila Thapa (Mark Information A/S) asked a question.

How can I read the language specific character example å, ø, æ using GetPathParameter method (IWebRequest)? When using this method I got the corrupted data. But I got the correct data when using GetQueryValue method.

  • Sharmila Thapa (Mark Information A/S)

    Sorry It is encoded. I have character Å in path parameter but I got Ã…

    Tried with FIX-CODEPAGE, but doesn't help.

  • Peter Judge (Progress Software)

    @Sharmila Thapa (Mark Information A/S)​  What codepage (-cpinternal) are you using?

     

    And just to confirm, when you GET <instance>/web/hello/Å?str=Å and you have a handler defined as handlerX=myWH: /hello/{first} , in the HandleGet() in myWH, you do something like

    1. /* Default handler for the HTTP GET method
    2. @param IWebRequest The request being serviced
    3. @return integer An optional status code. A zero or null value means this
    4. method will deal with all errors */
    5. method override protected integer HandleGet( input pReq as IWebRequest):
    6. message pReq:GetPathParameter('first').
    7. // bad
    8. message pReq:URI:GetQueryValue('str').
    9. // good
    10. end method.

     

     

     

    • Sharmila Thapa (Mark Information A/S)

      Hi @Peter Judge (Progress Software)​ ,

      It uses -cpinternal = ISO8859-1.

      And My URI looks like /web/profiles/{profile_id}/details >> to display the details of {profile_id}

      And the method looks like:

        METHOD OVERRIDE PROTECTED INTEGER HandleGet(INPUT pclRequest AS IWebRequest):    

          DEFINE VARIABLE ichProfileId   AS CHARACTER     NO-UNDO.

      ichProfileId  = pclRequest:GetPathParameter("profile_id":U).

      END METHOD.

       

      I tried to use it as query parameter and get the value with GetQueryValue method, there is no issue with GetQueryValue method.

      But as per the structure of my URI, I have to use GetPathParameter.

       

      • Peter Judge (Progress Software)

        It's definitely related to cpinternal: you'll find that if you set the agent's -cpinternal to UTF-8 things will appear as you expect them to. I think the query string stuff works because those values are stored in (basically) UTF-8 strings and there's some conversion going on.

         

        I think it's worth logging this difference in behaviour (between path params and query strings) as a bug with tech support.

         

        [edit] I think the issue relates to the fact that the query string is URI encoded, as is the path value, but the path parameter is not.

         

         

      • Sharmila Thapa (Mark Information A/S)

        Hi @Peter Judge (Progress Software)​ ,

        Is there any other workaround to solve this issue as it works with GetQueryValue? Because we are in the process of moving to UTF-8 but not sooner and also need to fix this for previous released versions.

        And I don't understand if the bug is to fix GetQueryValue to make it stop working and have it "consistent" with GetPathParameter, or to make GetPathParameter work just like GetQueryValue, which is what I would expect 😊

         

      • Peter Judge (Progress Software)

        The fix would be to make the path parameter URI-encoded, which is what the query strings do (so work like your expectations).

      • Peter Judge (Progress Software)

        You can work around it using code like the below. It uses the path segment instead of the CGI value. It assumes that you can only have a path parameter name once in the URL.

         

        1. METHOD OVERRIDE PROTECTED INTEGER HandleGet(INPUT pclRequest AS IWebRequest):
        2. DEFINE VARIABLE ichProfileId AS CHARACTER NO-UNDO.
        3. define variable idx as integer no-undo.
        4.  
        5. // Use the Path value (not the URI_<name> cgi value) because the Path is URI encoded,
        6. // and the cgi value is not
        7. assign idx = lookup('~{profile_id}':u, pclRequest:UriTemplate, '/':u).
        8. if idx eq 0 then
        9. ichProfileId = pclRequest:GetPathParameter("profile_id":U).
        10. else
        11. // idx is off-by-one bcause the path includes /web and the URI template does not
        12. assign ichProfileId = OpenEdge.Net.URI:Decode(entry(idx + 1, pclRequest:URI:Path, '/':u)).
        13. END METHOD.

         

         

         

      • Sharmila Thapa (Mark Information A/S)

        Hi @Peter Judge (Progress Software)​ ,

        Thanks a lot. It solves my problem with a small change on following line:

        assign ichProfileId = OpenEdge.Net.URI:Decode(entry(idx + 1, pclRequest:URI:Path, '/':u)). Instead of +1, it is +2 as the path also includes /ProjectName before /web.

        Thank you for your support.

        Have a nice day.

         

      • Bo Haslund (Mark Information A/S)

        Hi @Peter Judge (Progress Software)​ , big thanks for the help.

        We tested today with URI-Encoding UTF-8, and everything works perfect without you work-around.

10 of 12