HTML: application/x-www-form-urlencoded-VBForums
Results 1 to 8 of 8

Thread: HTML: application/x-www-form-urlencoded

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    HTML: application/x-www-form-urlencoded

    Is there a limit to the amount of data you can POST with
    application/x-www-form-urlencoded?
    I thought I hada problem with my CGI script because I couldn't POST more
    than 47kb as a string.
    But when I changed the server from IIS to Apache, the amount increased to
    69kb.

    This implied a built in limit of the server.

    Anyone know if this is configurable?

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904

    Re: HTML: application/x-www-form-urlencoded

    Maximum post side is usually measured in MB not KB

    What is it you are trying to send?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Re: HTML: application/x-www-form-urlencoded

    Im only sending a series of numbers added together in a string.

    To demonstrate what is happening download CVMichaels example CGI program
    http://www.vbforums.com/showthread.p...&highlight=cgi
    (bottom post in thread) and add a couple of lines to write the buffer to a log file e.g
    VB Code:
    1. Sub GetFormData()
    2.     Dim DataLen As Long, sData As String, lBytesRead As Long, rc As Long
    3.    
    4.     If UCase(Trim(Environ("REQUEST_METHOD"))) = "POST" Then
    5.         DataLen = Val(Environ("CONTENT_LENGTH"))
    6.  
    7.         If DataLen > 0 Then
    8.             sData = String(DataLen, 0)
    9.             rc = ReadFile(hStdIn, ByVal sData, DataLen, lBytesRead, ByVal 0&)
    10.             sData = Left$(sData, lBytesRead)
    11. [B]            Open "log.txt" For Append As #29
    12.                 Write #29, sData
    13.             Close #29[/B]
    14.         End If
    15.     End If
    16.    
    17.     PairData sData
    18.     PairData Environ("QUERY_STRING")
    19. End Sub

    Now paste 70kb of data into the form field and submit it.
    Depending on your server you wont necessarily have all the data in the log file.

    Note that it is a string not a file upload.
    This is because my application is an ActiveX control that collects lots of data from a measureing instrument and adds it all together as a string.
    The Onclick command of the (HTML) button then passes this string value to the (HTML) form and submits it.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904

    Re: HTML: application/x-www-form-urlencoded

    Are you actually encoding the data in the url encoded format?

    I.e: variable1=value1&variable2=value2

    If you do not require your data to be in this format, then set the enctype atttribute on the form to text/plain or if it is binary data: application/octet-stream.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Re: HTML: application/x-www-form-urlencoded

    The data is expected in the url encoded format, Ill have to check whether it actually does get encoded properly.
    Im not sure how that could have this effect though...

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Camden, London Mode: PPI
    Posts
    4,904

    Re: HTML: application/x-www-form-urlencoded

    Url encoded is designed to ctransport nam/value paris from form fields. Each input element in the form with the name is transferred along with its value in the form:

    firstname=Joe&surname=Bloggs&age=16

    Should the data contain any white space or the +/= character they are encoded using their ascii hexadecimal equivilent.

    http://www.w3schools.com/html/html_ref_urlencode.asp

    I am still not sure what you are doing. Are you using an HTML form to submit the data? If so then why don't you use a file upload?

    If you are using an Active X control client side, then I would by pass the HTML form and submit the data driectly to the CGI script. Pasting 70KB of data into a text box crashes Internet Explorer and takes Firefox an eternity to send.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Re: HTML: application/x-www-form-urlencoded

    Looking at the data recieved, the name/value pairs are getting encoded correctly.
    The client has a piece of Scientific Instumentation connected to the PC and the ActiveX control sends commands to set it up and read data back from it.
    This means that the data is held in a string in the ActiveX control and is not actually a file until it reaches the server and is processed.

    Im not actually pasting the data into a text box, but that seemed to be the easiest way to demonstrate without uploading the whole project.
    There is a script on the web page which interacts with a hidden form to upload the data.
    Code:
    <SCRIPT LANGUAGE="VBSCRIPT" TYPE="text/vbscript">
    <!--
    sub JobDone(CurrentMode)
    		s=cstr(MyControl.Param5)
    		i=cstr(MyControl.Param6)
    
    		frm.Stage.value=i
    		frm.d.value=s
    		frm.submit
    
    end sub
    -->
    </SCRIPT>
    
    
    	 <FORM METHOD="POST" ACTION="mycgi.exe" NAME="frm" ENCTYPE="application/x-www-form-urlencoded"> 
    		<INPUT TYPE="HIDDEN" NAME="Stage" VALUE="100"> 
    		<INPUT TYPE="HIDDEN" NAME="d" VALUE="0"> 
    		<INPUT TYPE="hidden" NAME="Ident" VALUE="*IDENT*"></FORM>
    Stage tells the CGI program which step in the process is being done.
    d contains this massive long string of data
    Ident is a unique identifier to locate the correct directory to store the files on the server

    How would you submit the data to the CGI program directly from the ActiveX control?

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,723

    Re: HTML: application/x-www-form-urlencoded

    I did not actually try to mimic your error, but you might want to try to encode the data before you send it, like the Base64 encoding (wich was made specifically for http and email transfers)

    Use the code I made in this thread:
    http://www.vbforums.com/showthread.p...ghlight=encode
    About 3 posts down

    Use the Base64Encoding at client side (in your activex), and Base64Decoding to decode at server side
    Last edited by CVMichael; Feb 14th, 2005 at 07:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.