• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 05, 2019 at 04:31 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
17
Question by elenzil · Mar 30, 2016 at 04:58 PM · wwwhttppost

prevent UnityWebRequest.Post() from Url-Encoding the data ?

per the docs for UnityWebRequest.Post(), the post body "Will be URLEncoded via WWWTranscoder.URLEncode prior to transmission".

t$$anonymous$$s is crazy. nowhere does the HTTP spec require that POST data be URL-Encoded. a good HTTP client should assume the user (me) knows what they're doing and can URL-Encode their own data if required. look at Curl. does Curl automatically url-encode the body if the method is POST ? no. if you're writing an HTTP client and you find yourself diverging from what Curl does, check yourself. < /rant >

anyhow, is there a way to disable t$$anonymous$$s ? i've tried: setting the content type "text/plain" setting the UploadHandler's content type to "text/plain"

neither works.

a workaround that does seem to work but is a total hack is to use UnityWebRequest.Put() instead, and change the method to POST before Sending it.

also, t$$anonymous$$s is a change from the previous WWW HTTP Client framework, and the statement in the manual that "For end-users who only employ common WWW use cases, transitioning to the new system should be almost a find-and-replace process." is way off-base because of t$$anonymous$$s.

Comment
Comments Locked
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
20
Best Answer

Answer by elenzil · Mar 30, 2016 at 05:25 PM

better workaround than the WebRequest.Put() hack is to build a WebRequest 'from scratch':

   request                 = new UnityWebRequest(url);
   request.uploadHandler   = new UploadHandlerRaw(myStringToByteArrayConverter(body));
   request.downloadHandler = new DownloadHandlerBuffer();
   request.method          = UnityWebRequest.kHttpVerbPOST;
Comment
Comments Locked · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image elenzil · Apr 21, 2017 at 11:53 PM 3
Share
avatar image nilsubimax elenzil · Sep 28, 2017 at 01:09 PM 2
Share
avatar image elenzil nilsubimax · Sep 28, 2017 at 04:07 PM 0
Share
avatar image Fragmental elenzil · Apr 04, 2018 at 06:44 AM 1
Share
avatar image Zero_MSN · Oct 11, 2017 at 07:03 PM 0
Share
avatar image Eric-Eidel · Nov 06, 2017 at 09:12 AM 0
Share
avatar image tarahugger · Apr 18, 2018 at 01:48 PM 0
Share
avatar image AlexAba · Feb 02, 2019 at 07:28 PM 0
Share
Show more comments

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

50 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

HTTP Response Headers? 3 Answers

Upload large files 0 Answers

POST to HTTP not working 2 Answers

How to use POST method to enter data to web service? 1 Answer

Blank web server response in multiple type data submission 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges