URL encode Referer in headerMap in Gatling - header

Might be an issue with brackets, but how do I parameterize a string as URL encoded in a headerMap in Gatling?
I am trying this:
"Referer"->"https://qa1.xxx/Innlogging.jsp?resource_url=https%3A%2F%2Fqa1.yyy%3A443%2Fhpp-webapp%2Fhentpasient.html").queryParam("ticket", "${epj_ticket}"),

Related

Special characters parsing in Ktor

I am trying to parse some special characters through the api's with Ktor in a KMM project but it seems like Ktor doesn't support it ?.
For eg :- I am trying to parse "Saut� Pans" here "�" is a special character and Ktor throws an exception saying :- io.ktor.utils.io.charsets.MalformedInputException: Input length = 1. Now I have tried passing different headers for example passing different ContentType to UTF-8 or ISO-8859-2 but didn't help.
Whereas parsing the same api response with Gson() works for me.
Any solution or workaround so that for now so that I can parse such kind of special characters in my response ?
You could try out
install(ContentEncoding){
gzip()
}

JMeter encode URL

I have to test the below URL that contains special char:
url\search.html?q=*&Filters=template_fac_s:3f87222389034212a868c5c0cd12cacc|market_l1_fac_sm:e73956c2506442399dd73ed1eb0ec165
I am getting this error:
Response message: Non HTTP response message: Illegal character in query at index 121: url/search.html?q=*&Filters=template_fac_s:3f87222389034212a868c5c0cd12cacc|market_l1_fac_sm:e73956c2506442399dd73ed1eb0ec165
I think I need to encode the URL but I do not know how to do it . Does anyone know how to do this , can someone help.
Thanks.
JMeter provides __urlencode function which replaces characters which are not allowed in URL with url-encoded equivalents
References:
Understanding HTML Form Encoding: URL Encoded and Multipart Forms
Apache JMeter Functions - An Introduction

Encoded path is encoded again

I have to make a request:
* url foo
* path bar
* path code
Code is retrieved from another request and I receive it url encoded.
The problem is when I put it in the path, karate encode it again.
Ex: I receive zxc1J%2BV%2FMnb and in path it becomes zxc1J%252BV%252FMnb.
%2Bis replaced by %252B.
When I decode received code and put it in path, it is not encoded.
My javascript function to decode is :
* def codeDecoded = decodeURIComponent(code)
and encoding function is * def codeEncoded = encodeURIComponent(codeDecoded)
Am I missing smth? What is wrong? How can I manage this? Thanks.
Edit:
#Peter Thomas I try my last chance, because I already showed the prb to someone from server and he didn't understand why karate encodes again smth already encoded and doesn't encode smth decoded.
So my first request is a POST request, which returns an encoded code in responseHeaders. Ex: GVkX1%2FKZEi%2FWQ.
In my second request I have to take this code and put it in the path ex: url/GVkX1%2FKZEi%2FWQ.
The problem is that karate transforms it to url/GVkX1%252FKZEi%252FWQ . And I don't need it. And if I decode url/GVkX1%2FKZEi%2FWQ before to put it in path, the url in karate is url/GVkX1/KZEi/WQ. When put in path, the decoded code is not encoded in karate. I hope it is more understandable.
Yes Karate will always encode the path you provide for your convenience. This is what 99% of users expect anyways.
There is nothing wrong with using a custom function to decode and ensure you pass un-encoded URL / path values to Karate, so by all means, please continue to do so !
Edit: quite likely the way you tried to decode may be wrong, try this:
* def encoded = 'zxc1J%2BV%2FMnb'
* def decoded = java.net.URLDecoder.decode(encoded, 'UTF-8')
* print decoded
Which prints:
[print] zxc1J+V/Mnb

sending € character to web server via VBA

I am using MSXML2.XMLHTTP60 to send text messages via VBA using a web server. I cannot understand why the € symbol is not displayed when receiving a text message. Other special characters, such as ò,à,è etc are displayed after a conversion function I wrote (for example à is encoded as "%E0"). I suppose that web server is expecting charset iso 8859-1 which doe not support € symbol. Therefore how can I solve this problem?
If your request is a POST request then you can specify header for Content-Type with encoding e.g. like this:
objHTTP.Open "POST", ...
objHTTP.setRequestHeader "Content-Type", "text/html; charset=utf-8"
But for GET request the URL with possible query string parameters will be encoded as ASCII. Read e.g. this post.
Using UTF-8 as your character encoding should solve such problems. It may also remove the need for your conversion function. I'm not sure how to set the encoding in your web server, but that's usually well documented.

MediaWiki API and encoding

I'm using the MediaWiki API to update some pages with an experimental robot.
This robot uses the Java Apache HTTP-client library to update the pages.
(...)
PostMethod postMethod = new PostMethod("http://mymediawikiinstallation/w/api.php");
postMethod.addParameter("action","edit");
postMethod.addParameter("title",page.replace(' ', '_'));
postMethod.addParameter("summary","trying to fix this accent problem");
postMethod.addParameter("text",content);
postMethod.addParameter("basetimestamp",basetimestamp);
postMethod.addParameter("starttimestamp",starttimestamp);
postMethod.addParameter("token",token);
postMethod.addParameter("notminor","");
postMethod.addParameter("format","xml");
int status = httpClient.executeMethod(postMethod);
(...)
However the 'content' string contains some accents. System.out.prinln(content) looks OK, but the accentuated characters in the wiki look bad. E.g. 'Val�rie' instead of 'Valérie'.
How can I fix this?
OK, changing the request header fixed the problem.
postMethod.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
In my PHP code to talk to the Mediawiki API I used urlencode to encode the title parameter, and this seems to work fine.