src/include/common/http/HTTPHeader.h

00001 /*
00002  * Copyright (C) 2003-2007 Funambol, Inc
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 version 2 as
00006  * published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00016  * 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);
00043 
00044         /*
00045          * Get the size in bytes of this HTTP header
00046          */
00047         unsigned int getSize();
00048         const char* getVersion();
00049         unsigned int getStatus();
00050         const char* getStatusMessage();
00051         const char* getContent();
00052         unsigned int getHeadersCount();
00053         char** getHeader(unsigned int index);
00054         const char* getHeaderValue(const char* header);
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();
00062     };
00064 #endif

Generated on Tue Oct 30 15:11:25 2007 for Funambol C++ Client Library by  doxygen 1.5.2