OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | List of all members
ossimHttpResponse Class Reference

#include <ossimHttpResponse.h>

Inheritance diagram for ossimHttpResponse:
ossimWebResponse ossimObject ossimReferenced ossimCurlHttpResponse

Public Member Functions

 ossimHttpResponse ()
 
ossimByteStreamBufferheaderBuffer ()
 
const ossimByteStreamBufferheaderBuffer () const
 
ossimByteStreamBufferbodyBuffer ()
 
const ossimByteStreamBufferbodyBuffer () const
 
std::iostream & headerStream ()
 
std::iostream & bodyStream ()
 
virtual std::istream * getInputStream ()
 This might have to change in the future if we start doing other protocols such as ftp scp, ... More...
 
virtual void clear ()
 Clears out the Response and prepares for a new response. More...
 
void convertHeaderStreamToKeywordlist ()
 This will parse out the response code from the status line and initialize the header variables into a keywordlist. More...
 
virtual void clearLastError ()
 
virtual ossimString getLastError () const
 
ossimKeywordlistheaderKwl ()
 
const ossimKeywordlistheaderKwl () const
 
ossim_int64 getContentLength () const
 
ossimString getHeaderValue (const ossimString &headerName) const
 
const ossimStringstatusLine () const
 
ossim_uint32 getStatusCode () const
 
- Public Member Functions inherited from ossimWebResponse
 ossimWebResponse ()
 
void copyAllDataFromInputStream (ByteBuffer &buffer)
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Attributes

ossimKeywordlist m_headerKwl
 
ossimByteStreamBuffer m_headerBuffer
 
ossimByteStreamBuffer m_bodyBuffer
 
std::iostream m_headerStream
 
std::iostream m_bodyStream
 
ossimString m_statusLine
 
ossim_uint32 m_statusCode
 
 TYPE_DATA
 

Additional Inherited Members

- Public Types inherited from ossimWebResponse
typedef std::vector< char > ByteBuffer
 
- Public Attributes inherited from ossimWebResponse
 TYPE_DATA
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Detailed Description

Definition at line 21 of file ossimHttpResponse.h.

Constructor & Destructor Documentation

◆ ossimHttpResponse()

ossimHttpResponse::ossimHttpResponse ( )
inline

Definition at line 24 of file ossimHttpResponse.h.

27  {
28  clear();
29  }
virtual void clear()
Clears out the Response and prepares for a new response.
ossimByteStreamBuffer m_headerBuffer
std::iostream m_bodyStream
ossimByteStreamBuffer m_bodyBuffer
std::iostream m_headerStream

Member Function Documentation

◆ bodyBuffer() [1/2]

ossimByteStreamBuffer& ossimHttpResponse::bodyBuffer ( )
inline

Definition at line 33 of file ossimHttpResponse.h.

33 {return m_bodyBuffer;}
ossimByteStreamBuffer m_bodyBuffer

◆ bodyBuffer() [2/2]

const ossimByteStreamBuffer& ossimHttpResponse::bodyBuffer ( ) const
inline

Definition at line 34 of file ossimHttpResponse.h.

34 {return m_bodyBuffer;}
ossimByteStreamBuffer m_bodyBuffer

◆ bodyStream()

std::iostream& ossimHttpResponse::bodyStream ( )
inline

Definition at line 37 of file ossimHttpResponse.h.

Referenced by ossimCurlHttpRequest::curlWriteResponseBody().

37 {return m_bodyStream;}
std::iostream m_bodyStream

◆ clear()

virtual void ossimHttpResponse::clear ( )
inlinevirtual

Clears out the Response and prepares for a new response.

Definition at line 45 of file ossimHttpResponse.h.

46  {
50  m_statusLine = "";
51  m_statusCode = 200;
52  }
ossim_uint32 m_statusCode
ossimKeywordlist m_headerKwl
ossimByteStreamBuffer m_headerBuffer
ossimByteStreamBuffer m_bodyBuffer
ossimString m_statusLine

◆ clearLastError()

virtual void ossimHttpResponse::clearLastError ( )
inlinevirtual

Definition at line 59 of file ossimHttpResponse.h.

59 {m_statusCode = 200;m_statusLine="";}
ossim_uint32 m_statusCode
ossimString m_statusLine

◆ convertHeaderStreamToKeywordlist()

void ossimHttpResponse::convertHeaderStreamToKeywordlist ( )

This will parse out the response code from the status line and initialize the header variables into a keywordlist.

Definition at line 5 of file ossimHttpResponse.cpp.

References ossimKeywordlist::clear(), getline(), m_headerBuffer, m_headerKwl, m_statusCode, m_statusLine, ossimKeywordlist::parseStream(), ossimString::split(), and statusLine().

Referenced by ossimCurlHttpRequest::getContentLength(), ossimCurlHttpRequest::getResponse(), and ossim::CurlStreamBuffer::loadBlock().

6 {
9 
10  std::istream in(&buf);
11  in.seekg(0); // make sure we are at the begining
12  // skip method type
13  //
14  std::string statusLine;
17 
19  std::vector<ossimString> statusLineArray;
20  m_statusLine.split(statusLineArray, " ");
21  if(statusLineArray.size() > 1)
22  {
23  m_statusCode = statusLineArray[1].toUInt32();
24  }
25  else
26  {
27  m_statusCode = 0;
28  }
29 }
ossim_uint32 m_statusCode
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
std::istream & getline(std::istream &is, ossimString &str, char delim)
Definition: ossimString.h:916
ossimKeywordlist m_headerKwl
ossimByteStreamBuffer m_headerBuffer
const ossimString & statusLine() const
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossimString m_statusLine
virtual bool parseStream(ossim::istream &is, bool ignoreBinaryChars)
deprecated method

◆ getContentLength()

ossim_int64 ossimHttpResponse::getContentLength ( ) const

Definition at line 38 of file ossimHttpResponse.cpp.

References ossimString::empty(), ossimKeywordlist::find(), m_headerKwl, and ossimString::toInt64().

Referenced by ossim::CurlStreamBuffer::loadBlock().

39 {
40  ossim_float64 result = -1;
41  ossimString contentLength = m_headerKwl.find("Content-Length");
42 
43  if(!contentLength.empty())
44  {
45  result = contentLength.toInt64();
46  }
47 
48  return result;
49 }
const char * find(const char *key) const
ossimKeywordlist m_headerKwl
double ossim_float64
bool empty() const
Definition: ossimString.h:411
ossim_int64 toInt64() const

◆ getHeaderValue()

ossimString ossimHttpResponse::getHeaderValue ( const ossimString headerName) const

Definition at line 31 of file ossimHttpResponse.cpp.

References ossimKeywordlist::find(), and m_headerKwl.

32 {
33  ossimString result = m_headerKwl.find(headerName);
34 
35  return result;
36 }
const char * find(const char *key) const
ossimKeywordlist m_headerKwl

◆ getInputStream()

virtual std::istream* ossimHttpResponse::getInputStream ( )
inlinevirtual

This might have to change in the future if we start doing other protocols such as ftp scp, ...

etc.

We currently will return the main input stream that can be used to read the bytes returned from the request. If you need access to say a header stream from an http protocol then you can dynamic_cast to an ossimHttpResponse.

Implements ossimWebResponse.

Definition at line 39 of file ossimHttpResponse.h.

40  {return static_cast<std::istream*>(&m_bodyStream);}
std::iostream m_bodyStream
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20

◆ getLastError()

virtual ossimString ossimHttpResponse::getLastError ( ) const
inlinevirtual

Definition at line 61 of file ossimHttpResponse.h.

61 {return ((m_statusCode == 200)?ossimString(""):m_statusLine);}
ossim_uint32 m_statusCode
ossimString m_statusLine

◆ getStatusCode()

ossim_uint32 ossimHttpResponse::getStatusCode ( ) const
inline

◆ headerBuffer() [1/2]

ossimByteStreamBuffer& ossimHttpResponse::headerBuffer ( )
inline

Definition at line 31 of file ossimHttpResponse.h.

31 {return m_headerBuffer;}
ossimByteStreamBuffer m_headerBuffer

◆ headerBuffer() [2/2]

const ossimByteStreamBuffer& ossimHttpResponse::headerBuffer ( ) const
inline

Definition at line 32 of file ossimHttpResponse.h.

32 {return m_headerBuffer;}
ossimByteStreamBuffer m_headerBuffer

◆ headerKwl() [1/2]

ossimKeywordlist& ossimHttpResponse::headerKwl ( )
inline

◆ headerKwl() [2/2]

const ossimKeywordlist& ossimHttpResponse::headerKwl ( ) const
inline

Definition at line 64 of file ossimHttpResponse.h.

64 {return m_headerKwl;}
ossimKeywordlist m_headerKwl

◆ headerStream()

std::iostream& ossimHttpResponse::headerStream ( )
inline

Definition at line 36 of file ossimHttpResponse.h.

Referenced by ossimCurlHttpRequest::curlWriteResponseHeader().

36 {return m_headerStream;}
std::iostream m_headerStream

◆ statusLine()

const ossimString& ossimHttpResponse::statusLine ( ) const
inline

Definition at line 67 of file ossimHttpResponse.h.

Referenced by convertHeaderStreamToKeywordlist().

67 {return m_statusLine;}
ossimString m_statusLine

Member Data Documentation

◆ m_bodyBuffer

ossimByteStreamBuffer ossimHttpResponse::m_bodyBuffer
protected

Definition at line 73 of file ossimHttpResponse.h.

◆ m_bodyStream

std::iostream ossimHttpResponse::m_bodyStream
protected

Definition at line 75 of file ossimHttpResponse.h.

◆ m_headerBuffer

ossimByteStreamBuffer ossimHttpResponse::m_headerBuffer
protected

Definition at line 72 of file ossimHttpResponse.h.

Referenced by convertHeaderStreamToKeywordlist().

◆ m_headerKwl

ossimKeywordlist ossimHttpResponse::m_headerKwl
protected

◆ m_headerStream

std::iostream ossimHttpResponse::m_headerStream
protected

Definition at line 74 of file ossimHttpResponse.h.

◆ m_statusCode

ossim_uint32 ossimHttpResponse::m_statusCode
protected

Definition at line 77 of file ossimHttpResponse.h.

Referenced by convertHeaderStreamToKeywordlist().

◆ m_statusLine

ossimString ossimHttpResponse::m_statusLine
protected

Definition at line 76 of file ossimHttpResponse.h.

Referenced by convertHeaderStreamToKeywordlist().

◆ TYPE_DATA

ossimHttpResponse::TYPE_DATA
protected

Definition at line 79 of file ossimHttpResponse.h.


The documentation for this class was generated from the following files: