src/include/common/http/HTTPHeader.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 
00020 // This class represents an HTTP header as read from a buffer or stream
00021 //
00022 #include "base/fscapi.h"
00023 
00024 #ifndef INCL_HTTP_HEADER
00025     #define INCL_HTTP_HEADER
00026 
00028     #define DIM_HEADERS 50
00029     #define MSG_BAD_PROTOCOL "BAD PROTOCOL"
00030 
00031     class HTTPHeader {
00032     private:
00033         char* version;
00034         unsigned int status;
00035         char* statusMessage;
00036         char* content;
00037         unsigned int headersCount;
00038         char* headers[DIM_HEADERS][2]; // up to DIM_HEADERS headers
00039         unsigned int size;
00040 
00041     public:
00042         HTTPHeader(char* buf) EXTRA_SECTION_03;
00043 
00044         /*
00045          * Get the size in bytes of this HTTP header
00046          */
00047         unsigned int getSize() EXTRA_SECTION_03;
00048         const char* getVersion() EXTRA_SECTION_03;
00049         unsigned int getStatus() EXTRA_SECTION_03;
00050         const char* getStatusMessage() EXTRA_SECTION_03;
00051         const char* getContent() EXTRA_SECTION_03;
00052         unsigned int getHeadersCount() EXTRA_SECTION_03;
00053         char** getHeader(unsigned int index) EXTRA_SECTION_03;
00054         const char* getHeaderValue(const char* header) EXTRA_SECTION_03;
00055 
00056         /*
00057          * Returns the content lenght specified with the header Content-length.
00058          * If the header is not found, -1 is returned.
00059          *
00060          */
00061         int getContentLength() EXTRA_SECTION_03;
00062     };
00064 #endif

Generated on Fri Apr 27 12:29:18 2007 for Funambol C++ Client Library by  doxygen 1.5.2