Panda3D
identityStream.cxx
1 // Filename: identityStream.cxx
2 // Created by: drose (09Oct02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "identityStream.h"
16 
17 // This module is not compiled if OpenSSL is not available.
18 #ifdef HAVE_OPENSSL
19 #include "httpChannel.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: IIdentityStream::Destructor
23 // Access: Published, Virtual
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 IIdentityStream::
27 ~IIdentityStream() {
28  if (_channel != (HTTPChannel *)NULL) {
29  _channel->body_stream_destructs(this);
30  _channel = NULL;
31  }
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: IIdentityStream::is_closed
36 // Access: Public, Virtual
37 // Description: Returns true if the last eof condition was triggered
38 // because the socket has genuinely closed, or false if
39 // we can expect more data to come along shortly.
40 ////////////////////////////////////////////////////////////////////
41 bool IIdentityStream::
42 is_closed() {
43  if ((_buf._has_content_length && _buf._bytes_remaining == 0) ||
44  _buf.is_closed()) {
45  return true;
46  }
47  clear();
48  return false;
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: IIdentityStream::close
53 // Access: Public, Virtual
54 // Description: Resets the IdentityStream to empty, but does not actually
55 // close the source BIO unless owns_source was true.
56 ////////////////////////////////////////////////////////////////////
57 void IIdentityStream::
58 close() {
59  _buf.close_read();
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: IIdentityStream::get_read_state
64 // Access: Public, Virtual
65 // Description: Returns an enum indicating how we are coming along in
66 // reading the document.
67 ////////////////////////////////////////////////////////////////////
68 INLINE IIdentityStream::ReadState IIdentityStream::
69 get_read_state() {
70  return _buf.get_read_state();
71 }
72 
73 #endif // HAVE_OPENSSL