Solved

Anatomy of HTTP post

Posted on 2004-03-24
7
371 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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
Pass through dll 2 99
Questions about INCLUDE FILES 2 43
Button on Table, name table1 not working 4 34
Making Table Thru ASP Response.write 5 19
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 informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 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