Solved

Anatomy of HTTP post

Posted on 2004-03-24
7
369 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Question.. 3 87
Update table value with join syntax 2 70
Bypass cross origin issues on development site 3 77
Select record with the most recent date 14 56
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 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