A. net class that sends HTTP data entities

Source: Internet
Author: User

The definition of the http data header is not written here.

Of course, the definition of the header can be written in this way.

Dim head As WebHeaderCollection
Head. Add ("name", "value ")
Send. Headers = head

Well, let's go to the topic. Below is a class, and a stream is received, which makes it easy to use! Imports System. Net
Imports System. io

Public Class httpClass http

Public Function httpsend () Function httpsend (ByVal uri As String, ByVal method As String, ByVal content As String) As Stream
Dim send As WebRequest = WebRequest. Create (uri)
Send. Method = method
Dim postdata As Byte ()
Postdata = System. Text. Encoding. Default. GetBytes (content)
Send. ContentLength = postdata. Length
Dim postStream As Stream = send. GetRequestStream ()
PostStream. Write (postdata, 0, postdata. Length)
PostStream. Close ()
Dim re As WebResponse = send. GetResponse
Return re. GetResponseStream
End Function

End Class

The corresponding receiving page can be written in the LOAD event as follows:

If Not IsDBNull (Request) Then
Dim a As Stream = Request. InputStream
End if

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.