zoukankan      html  css  js  c++  java
  • 一个.net发送HTTP数据实体的类

    这里暂时没有写到对http数据头的定义

    当然头的定义可以这样写

    Dim head As WebHeaderCollection
            head.Add(
    "name""value")
            send.Headers 
    = head

    好了,归到正题,下面是类,接收到的是一个stream,这样方便利用哈!
    Imports System.Net
    Imports System.io

    Public Class http

        
    Public Function httpsend(ByVal uri As StringByVal method As StringByVal content As StringAs 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



    对应的接收页面可以在LOAD事件里这样写

    If Not IsDBNull(Request) Then
                
    Dim a As Stream = Request.InputStream
    end if
  • 相关阅读:
    IMDB情感分类学习
    torchtext入门学习
    3.1日学习笔记|3.2日学习笔记
    2.24日学习笔记|2.26日学习笔记|2.27|2.28
    快慢指针问题
    2.21日学习笔记|2.22日学习笔记|2.23学习笔记
    dinic模板
    P1247 取火柴游戏 博弈nim
    博弈论
    P2161 [SHOI2009]会场预约 树状数组
  • 原文地址:https://www.cnblogs.com/aowind/p/296849.html
Copyright © 2011-2022 走看看