Go to the documentation of this file.00001
00002
00003
00004
00005 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00006
00007 namespace ACE
00008 {
00009 namespace INet
00010 {
00011
00012 ACE_INLINE
00013 int HeaderBase::get_content_length() const
00014 {
00015 ACE_CString lenstr;
00016 if (this->get (CONTENT_LENGTH, lenstr))
00017 {
00018 return ACE_OS::atoi (lenstr.c_str ());
00019 }
00020 return UNKNOWN_CONTENT_LENGTH;
00021 }
00022
00023 ACE_INLINE
00024 void HeaderBase::set_content_type(const ACE_CString& mime_type)
00025 {
00026 if (mime_type == UNKNOWN_CONTENT_TYPE)
00027 {
00028 this->remove (CONTENT_TYPE);
00029 }
00030 else
00031 {
00032 this->set (CONTENT_TYPE, UNKNOWN_CONTENT_TYPE);
00033 }
00034 }
00035
00036 ACE_INLINE
00037 ACE_CString HeaderBase::get_content_type() const
00038 {
00039 ACE_CString val = UNKNOWN_CONTENT_TYPE;
00040 this->get (CONTENT_TYPE, val);
00041 return val;
00042 }
00043
00044 ACE_INLINE
00045 void HeaderBase::clear ()
00046 {
00047 this->header_values_.reset ();
00048 }
00049
00050 ACE_INLINE
00051 void HeaderBase::add (const ACE_CString& name, const ACE_CString& value)
00052 {
00053 this->header_values_.insert (NVPair (name, value));
00054 }
00055
00056 ACE_INLINE
00057 void HeaderBase::remove (const ACE_CString& name)
00058 {
00059 this->header_values_.remove (NVPair (name, EMPTY));
00060 }
00061
00062 ACE_INLINE
00063 bool HeaderBase::get (const ACE_CString& name, ACE_CString& value) const
00064 {
00065 TNVMap::ITERATOR it (const_cast<TNVMap&> (this->header_values_));
00066 if (this->header_values_.find (NVPair (name), it) == 0)
00067 {
00068 value = (*it).second ();
00069 return true;
00070 }
00071 return false;
00072 }
00073
00074 ACE_INLINE
00075 bool HeaderBase::has (const ACE_CString& name) const
00076 {
00077 TNVMap::ITERATOR it (const_cast<TNVMap&> (this->header_values_));
00078 if (this->header_values_.find (NVPair (name), it) == 0)
00079 {
00080 return true;
00081 }
00082 return false;
00083 }
00084
00085 ACE_INLINE
00086 int HeaderBase::read_field (std::istream& str, ACE_CString& var, size_t maxlen, char delim)
00087 {
00088 int ch = str.get ();
00089 while (ch != eof_ && ch != delim && ch != '\n' && var.length () < maxlen)
00090 {
00091 var += ch;
00092 ch = str.get ();
00093 }
00094 return ch;
00095 }
00096
00097 ACE_INLINE
00098 int HeaderBase::read_ws_field (std::istream& str, ACE_CString& var, size_t maxlen)
00099 {
00100 int ch = str.get ();
00101 while (!ACE_OS::ace_isspace (ch) && ch != eof_ && var.length () < maxlen)
00102 {
00103 var += ch;
00104 ch = str.get ();
00105 }
00106 return ch;
00107 }
00108
00109 ACE_INLINE
00110 NVPair& NVPair::operator =(const NVPair& pair)
00111 {
00112 this->first (pair.first ());
00113 this->second (pair.second ());
00114 return *this;
00115 }
00116
00117 ACE_INLINE
00118 bool NVPair::operator ==(const NVPair& pair) const
00119 {
00120 return this->first_ == pair.first ();
00121 }
00122
00123 ACE_INLINE
00124 bool NVPair::operator <(const NVPair& pair) const
00125 {
00126 return this->first_ < pair.first ();
00127 }
00128
00129 ACE_INLINE
00130 const ACE_CString& NVPair::first (void) const
00131 {
00132 return this->first_;
00133 }
00134
00135 ACE_INLINE
00136 void NVPair::first (const ACE_CString& t1)
00137 {
00138 this->first_ = t1;
00139 }
00140
00141 ACE_INLINE
00142 const ACE_CString& NVPair::second (void) const
00143 {
00144 return this->second_;
00145 }
00146
00147 ACE_INLINE
00148 void NVPair::second (const ACE_CString& t2)
00149 {
00150 this->second_ = t2;
00151 }
00152
00153 }
00154 }
00155
00156 ACE_END_VERSIONED_NAMESPACE_DECL