protected override HTTPResponse ResetResponse(HTTPClient client,
     HTTPResponse response)
 {
   response = base.ResetResponse(client, response);
   CreateStream(response);
   return response;
 }
 protected virtual void CreateStream(HTTPResponse response)
 {
   response.contentStream = _stream;
   if (_writer != null)
   {
     _writer.Close();
     _writer = new BinaryWriter(_stream);
   }
 }
    protected override void OnDidReceiveData(HTTPResponse response,
        byte[] buffer, ulong length)
    {
      int len = (int)length;

      if (_writer == null)
      {
        if (_stream == null)
        {
          CreateStream(response);
        }
        _writer = new BinaryWriter(_stream);
      }

      _writer.Write(buffer, 0, len);
    }
 protected override void UpdateContentData(HTTPClient client,
     HTTPResponse response)
 {
   uint connectionID = client.ConnectionID;
   response.receivedContentLength =
     Bindings._URLClientGetResponseContentLengthRead(connectionID);
 }
Exemplo n.º 5
0
    protected void Update()
    {
      UpdateStateAndError();

      _response = _responseHandler.OnDidUpdate(this, _response);

      if (_error == null)
      {
        _error = _responseHandler.Error;
      }

      if (CheckDone() == true)
      {
        ReleaseResources();
      }
    }
Exemplo n.º 6
0
 public HTTPClient(HTTPRequest request = null,
     HTTPResponseHandler responseHandler = null)
 {
   _connectionID = Bindings.INVALID_CONNECTION_ID;
   _state = ConnectionState.Initialized;
   _connectionTimeout = DefaultConnectionTimeout;
   _error = null;
   _requestSent = false;
   _request = request;
   _response = null;
   _responseHandler = responseHandler;
 }
 protected abstract void UpdateContentData(HTTPClient client,
     HTTPResponse response);
 protected virtual HTTPResponse ResetResponse(HTTPClient client,
     HTTPResponse response)
 {
   response = CreateResponse(client);
   return response;
 }
    protected virtual HTTPResponse CreateResponse(HTTPClient client)
    {
      uint connectionID = client.ConnectionID;

      HTTPResponse response = new HTTPResponse();

      response.statusCode =
        Bindings._URLClientGetResponseStatusCode(connectionID);

      response.resumedContentLength =
        Bindings._URLClientGetResponseContentLengthResumed(connectionID);
      response.expectedReceiveContentLength =
        Bindings._URLClientGetResponseContentExpectedLength(connectionID);
      response.redirectCount =
        Bindings._URLClientGetResponseRedirectCount(connectionID);

      response.headers = CreateHeaders(client);

      return response;
    }
    public virtual HTTPResponse OnDidUpdate(HTTPClient client,
        HTTPResponse response)
    {
      if (client.State < ConnectionState.ReceivingData)
      {
        return response;
      }

      if (response == null)
      {
        response = CreateResponse(client);
      }

      while (true)
      {
        UpdateContentData(client, response);

        if (CheckNeedsResponseReset(client) == false)
        {
          break;
        }

        response = ResetResponse(client, response);
      }

      return response;
    }
 protected override void CreateStream(HTTPResponse response)
 {
   _stream = new MemoryStream();
   base.CreateStream(response);
 }