Solved

Anatomy of HTTP post

Posted on 2004-03-24
7
364 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 500 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now