Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Anatomy of HTTP post

Posted on 2004-03-24
7
370 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Suggested Solutions

Title # Comments Views Activity
SP to delete duplicates 15 72
INNER JOIN ? 8 50
document.getElementById not worj with 2 IDs with the same name 10 51
IIS 7 and executing pages using localhost 16 13
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 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…

840 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