dish/src/dish.cxx
//------------------------------------------------------------------------------------------
// This static function will read HTTP server reply from the given socket and will 
// unwrap Access command results from the HTTP block. Will return results of communication
// OK or will return NULL if error in communication.
//------------------------------------------------------------------------------------------
This static function will read HTTP server reply from the given socket and will
unwrap Access command results from the HTTP block. Will return results of communication
OK or will return NULL if error in communication.
This static function will read HTTP server reply from the given socket and will unwrap Access command results from the HTTP block . Will return results of communication OK or will return NULL if error in communication .
static char* receiveHttpReply(int socket) {
    char buf[1024];
    int reply_length;
    int readed;
    static char* reply = NULL;
    if(reply!=NULL) delete reply;
    reply = NULL;
    if(read_line(socket,buf,1024)) {        
        int status = parseReplyCommand(buf);
        if(status==400 || status==401) return NULL;         
        reply_length = ReadHeaders(socket); 
        if(reply_length>0) {                
            reply = new char [reply_length+1]; 
            int len = reply_length;
            readed = 0;
            while(len>0) {   
                int packet = recv(socket,reply+readed,reply_length-readed,0);
                if(packet<0) break;
                len-=packet;
                readed+=packet;
            }
            if(readed<reply_length) {
                delete reply;
                reply=NULL;
            } else {
                reply[readed]=0;
            }
        } 
        if(reply_length==0) {
            reply = new char [1];
            reply[0]=0;
            return reply;
        }
    }
    return reply;
}
static char * receiveHttpReply ( int socket ) { char buf [ 1024 ] ; int reply_length ; int readed ; static char * reply = NULL ; if ( reply != NULL ) delete reply ; reply = NULL ; if ( read_line ( socket , buf , 1024 ) ) { int status = parseReplyCommand ( buf ) ; if ( status == 400 || status == 401 ) return NULL ; reply_length = ReadHeaders ( socket ) ; if ( reply_length > 0 ) { reply = new char [ reply_length + 1 ] ; int len = reply_length ; readed = 0 ; while ( len > 0 ) { int packet = recv ( socket , reply + readed , reply_length - readed , 0 ) ; if ( packet < 0 ) break ; len -= packet ; readed += packet ; } if ( readed < reply_length ) { delete reply ; reply = NULL ; } else { reply [ readed ] = 0 ; } } if ( reply_length == 0 ) { reply = new char [ 1 ] ; reply [ 0 ] = 0 ; return reply ; } } return reply ; }
This static function will read HTTP server reply from the given socket and will
unwrap Access command results from the HTTP block.
This static function will read HTTP server reply from the given socket and will unwrap Access command results from the HTTP block .
// Reading reply header // Reading reply MIME-headers // Reading reply data itself // If we were unable to read data perfectly - error