Process Method

Summary
Read and decode a client HTTP data buffer in chunks and fill the HttpClientRequest properties.
Syntax
C#
C++/CLI
Python
public void Process( 
   byte[] readBuffer, 
   int offset, 
   int length 
) 
public: 
void Process(  
   array<byte>^ readBuffer, 
   int offset, 
   int length 
)  
def Process(self,readBuffer,offset,length): 

Parameters

readBuffer
HTTP client request data.

offset
Index of the first byte to decode.

length
The number of bytes to decode.

Remarks

You can call this method many times to decode chunks of client data as they received from an HTTP request.

Use the Execute property to decide when the request data is completely received and decoded.

This method will update the HttpClientRequest properties and fill the Headers and Args while processing.

Example
C#
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:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Jpip.Server Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.