JMeter URL Base64 encoding problems encountered

Source: Internet
Author: User
Tags base64 vars

In the process of using JMeter for interface testing, the string after the conversion of Base64 is added to the URL, always

Java.net.MalformedURLException:Illegalcharacter in URL.

A problem that was found to be a reference to the Base64jar package after finding the reason

Two solutions are now attached: both methods can be

Method One

Import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;

String res = Base64.encode (vars.get ("con"). GetBytes ());

Vars.put ("Base64content", res);


Method Two
Import Sun.misc.BASE64Decoder;

String res = new Sun.misc.BASE64Encoder (). Encode (Vars.get ("con"). GetBytes ());

Res=java.net.urlencoder.encode (res, "UTF-8");

Vars.put ("Base64content", res);

JMeter URL Base64 encoding problems encountered

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.