Beispiel #1
0
int ehttp:: read_header( int fd, void *cookie, string &header, MemoryBuffer &message )
{

    header="";
    unsigned int offset=0;
    int r = 0;
    while((offset=header.find("\r\n\r\n"))==string::npos )
    {
        input_buffer[0]=0;
        r=pRecv((void*)fd,&input_buffer[0],INPUT_BUFFER_SIZE,cookie);
        if( r < 0 )
            return EHTTP_ERR_GENERIC;
        input_buffer[r]=0;
        header+=input_buffer;
    }
    //message=header.substr(offset+4); // gotta have our shit globally i guess
    // gotta calculate somehow =/ hmmmm cuz r isnt good enough since some might be leftover
    // no cuz its teh offset in the full recieved header not our input buffer
    // input buffer is oging to change right we are interested in the last chunk of it only ahh
    DWORD inputPos = (offset + 4) % INPUT_BUFFER_SIZE;
    message.Add(&input_buffer[inputPos], r - inputPos);
    // then isntead of message add to our MemBuffer

    // can't we take the message from parse_message, and add it to our buffer if len > 0?
    // keep in mind that null will f**k us up =/ah so it would be pretty much this
    // and message= would be adding to mem buffer instead
    /* Fix the case where only "GET /xxxxx HTTP1.0\r\n\r\n" is sent (no other headers)*/
    if(offset == header.find("\r\n"))
        header=header.substr(0,offset+2);
    else
        header=header.substr(0,offset);
//	DebugMsg( "HTTPServer-embed","Header:-->%s<--\r\n",header.c_str());
//	DebugMsg( "HTTPServer-embed","Message:-->%s<--\r\n",message.c_str());
    return EHTTP_ERR_OK;
}
Beispiel #2
0
	int __cdecl ProtoSSL::mRecv(void *state, const char *buffer, unsigned int length) {
		int read_count = pRecv(state, buffer, length);

		if (read_count > 0) {
			connections_mutex_.lock();
			if (connections_.find(state) != connections_.end()) {
				ProtoSSL::Connection &connection = connections_[state];
				dump_.Write(SOCK_STREAM, IPPROTO_TCP, connection.RemoteEndpoint.Address, connection.RemoteEndpoint.Port,
					connection.LocalEndpoint.Address, connection.LocalEndpoint.Port, const_cast<char *>(buffer), length);

				base::EA_MITM::Log->Write(indigo::kLogType_Info, "EA::ProtoSSL", 
					"Recv: [%i] Received %i bytes from %s:%i", connection.ID, length, 
					connection.RemoteEndpoint.AddressString.c_str(), connection.RemoteEndpoint.Port);
			}
			connections_mutex_.unlock();
		}

		return read_count;
	}