Bug 36095 - Uri is longer than the maximum 32766 characters
Summary: Uri is longer than the maximum 32766 characters
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-11-20 09:16 UTC by John Miller [MSFT]
Modified: 2015-11-23 08:00 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Sample Project (1.29 MB, application/zip)
2015-11-20 09:16 UTC, John Miller [MSFT]
Details

Description John Miller [MSFT] 2015-11-20 09:16:48 UTC
Created attachment 13914 [details]
Sample Project

**Overview:**

   FormUrlEncodedContent throws an exception when the key/value pair is large. 

**Steps to Reproduce:**

   1. Run the attached sample on an iOS simulator

**Actual Results:**

   System.UriFormatException: Uri is longer than the maximum 32766 characters.
  at System.Uri.EscapeDataString (System.String stringToEscape) [0x00021] in /Users/builder/data/lanes/2356/3c0ec355/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System/Uri.cs:1829 
  at System.Net.Http.FormUrlEncodedContent.SerializeValue (System.String value) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.2.1.51/src/mono/mcs/class/System.Net.Http/System.Net.Http/FormUrlEncodedContent.cs:85 
  at System.Net.Http.FormUrlEncodedContent.EncodeContent (IEnumerable`1 nameValueCollection) [0x0005f] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.2.1.51/src/mono/mcs/class/System.Net.Http/System.Net.Http/FormUrlEncodedContent.cs:72 
  at System.Net.Http.FormUrlEncodedContent..ctor (IEnumerable`1 nameValueCollection) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.2.1.51/src/mono/mcs/class/System.Net.Http/System.Net.Http/FormUrlEncodedContent.cs:38 
  at test_uri_error.WebServices.UploadPhotoToServerUsingHttpClient (test_uri_error.PhotoClass pc) [0x00046] in /Users/joe/Projects/Learning/test_uri_error/test_uri_error/WebServices.cs:31 
  at test_uri_error.AppDelegate.FinishedLaunching (UIKit.UIApplication application, Foundation.NSDictionary launchOptions) [0x0005f] in /Users/joe/Projects/Learning/test_uri_error/test_uri_error/AppDelegate.cs:39 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2356/3c0ec355/source/maccore/src/UIKit/UIApplication.cs:77 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2356/3c0ec355/source/maccore/src/UIKit/UIApplication.cs:61 
  at test_uri_error.Application.Main (System.String[] args) [0x00008] in /Users/joe/Projects/Learning/test_uri_error/test_uri_error/Main.cs:12 

**Expected Results:**

   Max character limit is expected to be 65536 for .Net 4.5+

**Build Date & Platform:**

=== Xamarin Studio ===

Version 5.10 (build 871)
Installation UUID: e01c3049-a2d2-4e0a-aad8-afe6fb627c4d
Runtime:
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

Version: 0.20.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.1 (9079)
Build 7B91b

=== Xamarin.iOS ===

Version: 9.2.1.51 (Business Edition)
Hash: 3c0ec35
Branch: master
Build date: 2015-11-12 13:05:39-0500

=== Xamarin.Android ===

Version: 6.0.0.34 (Business Edition)
Android SDK: /Users/johnmiller/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.2
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.0.109 (Business Edition)

=== Build Information ===

Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 06:02:54-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.10.5

**Additional Information:**

   I can't seem to find the documentation supporting the new upper limit. 
   Similar issue was filed for RestSharp supporting that: https://github.com/FubarDevelopment/restsharp.portable/issues/12
   MSDN shows a 32766 limit for EscapeDataString: https://msdn.microsoft.com/en-us/library/system.uri.escapedatastring(v=vs.110).aspx
Comment 1 Marek Safar 2015-11-21 04:49:53 UTC
Fixed in master (bumped he limit)
Comment 2 Joseph Hanna 2015-11-22 05:24:58 UTC
Thanks for your prompt action Marek.  What is the new limit? We are uploading files that are multiple megabytes.
Comment 3 Marek Safar 2015-11-22 06:19:13 UTC
The limit is same as .net (0xFFF0). I am not sure why for multi megabytes files you need such long uri
Comment 4 Joseph Hanna 2015-11-22 14:01:12 UTC
Hi Marek

As per my sample, the issue is related to the encoded Form contents when POSTing, not the uri as the error message suggests. 

Joe
Comment 5 Marek Safar 2015-11-23 08:00:48 UTC
That's by design limitation of FormUrlEncodedContent. If you need to send large data looks for System.Net.Http.HttpContent implementation which suites you best.

Note You need to log in before you can comment on or make changes to this bug.