pike.git / lib / modules / SSL.pmod / Connection.pike

version» Context lines:

pike.git/lib/modules/SSL.pmod/Connection.pike:442:   }         //   // --- Old connection.pike below   //         State current_read_state;   State current_write_state; - string(8bit) left_over; + Stdio.Buffer read_buffer = Stdio.Buffer();   Packet packet;      //! Number of application data bytes sent by us.   int sent;      //! Bitfield with the current connection state.   ConnectionState state = CONNECTION_handshaking;      function(object,int|object,string:void) alert_callback;   
pike.git/lib/modules/SSL.pmod/Connection.pike:504:   //! Can be used to support a fallback redirect https->http.   void set_alert_callback(function(object,int|object,string:void) callback)   {    alert_callback = callback;   }      //! Low-level receive handler. Returns a packet, an alert, or zero if   //! more data is needed to get a complete packet.   protected Packet recv_packet(string(8bit) data)   { -  string(8bit)|Packet res; +  int(0..1)|Packet res;    -  +  read_buffer->add(data); +     // SSL3_DEBUG_MSG("SSL.Connection->recv_packet(%O)\n", data); -  if (left_over || !packet) -  { +  if (!packet)    packet = Packet(version, 2048); -  res = packet->recv( (left_over || "") + data); -  } -  else -  res = packet->recv(data); +     -  if (stringp(res)) +  res = packet->recv(read_buffer); +  +  if(objectp(res)) +  return [object(Packet)]res; +  +  if (res)    { /* Finished a packet */ -  left_over = [string]res; +     if (current_read_state) {    SSL3_DEBUG_MSG("SSL.Connection->recv_packet(): version=0x%x\n",    version);    return current_read_state->decrypt_packet(packet);    } else {    SSL3_DEBUG_MSG("SSL.Connection->recv_packet(): current_read_state is zero!\n");    return 0;    }    } -  else /* Partial packet read, or error */ -  left_over = 0; +     -  return [object]res; +  return 0;   }      //! Queues a packet for write. Handshake and and change cipher   //! must use the same priority, so must application data and   //! close_notifies.   void send_packet(Packet packet, int|void priority)   {    if (state & CONNECTION_local_closing) {    SSL3_DEBUG_MSG("SSL.Connection->send_packet: ignoring packet after close\n");    return;
pike.git/lib/modules/SSL.pmod/Connection.pike:923:    string(8bit) res = "";    Packet packet;    while (packet = recv_packet(data))    {    data = "";       if (packet->is_alert)    { /* Reply alert */    SSL3_DEBUG_MSG("SSL.Connection: Bad received packet\n");    if (alert_callback) -  alert_callback(packet, current_read_state->seq_num, left_over); +  alert_callback(packet, current_read_state->seq_num, +  (string)read_buffer);    if (this && packet)    send_packet(packet);    if ((!packet) || (!this) || (packet->level == ALERT_fatal))    return -1;    if (alert_callback)    break;    }    else    {    SSL3_DEBUG_MSG("SSL.Connection: received packet of type %d\n",