Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Anatomy of HTTP post

Posted on 2004-03-24
7
Medium Priority
?
380 Views
Last Modified: 2012-06-27
Hi Experts,

Someone is sending me a HTTP post ( NOT useing form elements, NOT querysring NOT even using a web browser to make the HTTP post ) to my asp page

How in asp to I read that post?

Regards,
Fouad Daniels
0
Comment
Question by:FouadDaniels
  • 4
  • 3
7 Comments
 
LVL 15

Accepted Solution

by:
deighc earned 2000 total points
ID: 10667622
I posted the same answer in your other question ;-)

You have to read the binary data from the Request object then convert the binary data to a string:

dim requestString

requestString= RSBinaryToString(Request.BinaryRead(Request.TotalBytes))

Function RSBinaryToString(xBinary)
     Dim Binary
     'MultiByte data must be converted To VT_UI1 | VT_ARRAY first.
     If vartype(xBinary)=8 Then Binary = MultiByteToBinary(xBinary) Else Binary = xBinary
       
     Dim RS, LBinary
     Const adLongVarChar = 201
     Set RS = CreateObject("ADODB.Recordset")
     LBinary = LenB(Binary)
       
     If LBinary>0 Then
          RS.Fields.Append "mBinary", adLongVarChar, LBinary
          RS.Open
          RS.AddNew
          RS("mBinary").AppendChunk Binary
          RS.Update
          RSBinaryToString = RS("mBinary")
     Else
          RSBinaryToString = ""
     End If
End Function

This will give a variable - requestString - with the string representation of the binary data.
0
 

Author Comment

by:FouadDaniels
ID: 10667864
type mismatch:
MultiByteToBinary

I dont have that function and the code craches.

Regards,
Fouad Daniels
0
 
LVL 15

Expert Comment

by:deighc
ID: 10667894
Sorry, I forgot to paste that function as well.  :-(

Function MultiByteToBinary(MultiByte)
      Dim RS, LMultiByte, Binary
      Const adLongVarBinary = 205
      Set RS = CreateObject("ADODB.Recordset")
      LMultiByte = LenB(MultiByte)
      If LMultiByte>0 Then
            RS.Fields.Append "mBinary", adLongVarBinary, LMultiByte
            RS.Open
            RS.AddNew
            RS("mBinary").AppendChunk MultiByte & ChrB(0)
            RS.Update
            Binary = RS("mBinary").GetChunk(LMultiByte)
      End If
      MultiByteToBinary = Binary
End Function
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:FouadDaniels
ID: 10668054
If you post this at my previous question aswell I will give you the other 500 points aswell
0
 
LVL 15

Expert Comment

by:deighc
ID: 10668102
> If you post this at my previous question aswell I will give you the other 500 points aswell

Already done. Have a look...

And thanks for the points.
0
 

Author Comment

by:FouadDaniels
ID: 10668232
Where can I find a good tutorial on what the hell is going on in your script. I can follow almsote all of it but the parts I dont follow are wickidly unknown to me.

Regards,

Fouad Daniels
0
 
LVL 15

Expert Comment

by:deighc
ID: 10668414
I plunderd most of the code from somewhere (can't remember where - it was a long time ago).

There are many such functions out there. Some of them use the ADO Stream object and some, like the ones I posted, use an ADO Recordset object.

The function MultiByteToBinary() unsurprisingly converts a multi-byte array (sometimes called a safe-array, or even just an array of bytes) into a single binary value. It works by creating an empty recordset object then adding a BLOB field to it, then using the AppendChunk method to add the binary data to the new field. In effect this is just writing the value of binary array into a BLOB field but the AppendChunk method lets you specify either character or binary data. GetChunk does the opposite in that it pulls out the BLOB data from the field. The truth is I don't really know how it converts between a byte array and single binary value. This is just some intrinsic ADO functionality and I have to be happy with the explanation that "it just works". It seems that AppendChunk will convert the byte array into binary and append it to any existing data that's in the field (and since we've just created the field we know that it's empty).

The function RSBinaryToString() is kind-of similar except that the newly created field is a text field instead of a BLOB field. After appending the chunk of binary data to the field the function simply returns the .value property of the field. Since it's a string data type a string is returned.

The great mystery to me is why you can't just append the byte array to the text field and do away with the MultiByteToBinary() function. But again, I think that's getting into the serious nitty-gritty of ADO so once again I calm down by reminding myself "it works".

Hope that gives you some idea what's going on. Not rocket science but quite nifty.

AppendChunk method of ADO Field object:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthappchunk.asp?frame=true

GetChunk method of ADO Field object:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthappchunk.asp?frame=true
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question