BodyData Property

Summary
Gets the contents of the incoming HTTP entity body.
Syntax
C#
VB
C++
public byte[] BodyData { get; } 
  
Public ReadOnly Property BodyData As Byte() 
public: 
property array<byte>^ BodyData { 
   array<byte>^ get(); 
} 

Property Value

An array of bytes representing the contents of the incoming HTTP content body.

Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Jpip; 
using Leadtools.Jpip.HttpServer; 
using Leadtools.Jpip.RequestDecoder; 
using Leadtools.Jpip.RequestEncoder; 
using Leadtools.Jpip.Client.WinForms; 
using Leadtools.Jpip.Client.InteractiveDecoder; 
using Leadtools.Jpip.Server; 
using Leadtools.Jpip.Logging; 
 
public void ProcessClientRequests() 
{ 
   Leadtools.Examples.Support.SetLicense(); 
   HttpClientRequest clientRequest = null; 
   HttpRequestDecoder decoder = null; 
   Socket client; 
   client = GetClientSocket(); 
   clientRequest = new HttpClientRequest(); 
   byte[] clientData; 
   int received; 
 
   do 
   { 
      clientData = new byte[client.ReceiveBufferSize]; 
      received = client.Receive(clientData); 
      clientRequest.Process(clientData, 0, received); 
   } while (clientRequest.Execute); //receive data until a complete request is received 
 
   Console.WriteLine("Client request received: {0}", clientRequest.CompleteMessage); 
   File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "ServerRequests.dat"), clientRequest.BodyData); 
   decoder = new HttpRequestDecoder(clientRequest); 
   Console.WriteLine("Server will process client image {0}", decoder.Fields.RequestTargetFields.Target); 
   //Process client request... 
   client.Close(); 
} 
 
private Socket GetClientSocket() 
{ 
   Socket listenSocket = new Socket(AddressFamily.InterNetwork, 
                                     SocketType.Stream, 
                                     ProtocolType.Tcp); 
   IPAddress hostIP = IPAddress.Parse("127.0.0.1"); 
   int port = 107; 
   IPEndPoint ep = new IPEndPoint(hostIP, port); 
   listenSocket.Bind(ep); 
   // start listening 
   listenSocket.Listen(10); 
   //a client should send a request to the listening address 
   Socket _client = listenSocket.Accept(); 
   listenSocket.Close(); 
   return _client; 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Jpip 
Imports Leadtools.Jpip.HttpServer 
Imports Leadtools.Jpip.RequestDecoder 
Imports Leadtools.Jpip.RequestEncoder 
Imports Leadtools.Jpip.Client.WinForms 
Imports Leadtools.Jpip.Client.InteractiveDecoder 
Imports Leadtools.Jpip.Server 
Imports Leadtools.Jpip.Logging 
 
Public Class HttpServerCommunication 
   Public Sub ProcessClientRequests() 
 
      Dim clientRequest As HttpClientRequest = Nothing 
      Dim decoder As HttpRequestDecoder = Nothing 
      Dim client As Socket 
 
      client = GetClientSocket() 
      clientRequest = New HttpClientRequest() 
      Dim clientData As Byte() 
 
      Dim received As Integer 
 
      Do 
         clientData = New Byte(client.ReceiveBufferSize - 1) {} 
 
         received = client.Receive(clientData) 
 
 
         clientRequest.Process(clientData, 0, received) 
 
      Loop While clientRequest.Execute 'receive data until a complete request is received 
 
      Console.WriteLine("Client request received: {0}", clientRequest.CompleteMessage) 
 
      File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "ServerRequests.dat"), clientRequest.BodyData) 
      decoder = New HttpRequestDecoder(clientRequest) 
 
      Console.WriteLine("Server will process client image {0}", decoder.Fields.RequestTargetFields.Target) 
 
 
      'Process client request... 
      '... 
 
      client.Close() 
   End Sub 
 
   Private Function GetClientSocket() As Socket 
 
      Dim listenSocket As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) 
 
      Dim hostIP As IPAddress = IPAddress.Parse("127.0.0.1") 
      Dim port As Integer = 107 
 
      Dim ep As IPEndPoint = New IPEndPoint(hostIP, port) 
 
      listenSocket.Bind(ep) 
 
      ' start listening 
      listenSocket.Listen(10) 
 
      'a client should send a request to the listening address 
      Dim client As Socket = listenSocket.Accept() 
 
      listenSocket.Close() 
 
      Return client 
   End Function 
End Class 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Jpip.Server Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.