Ejemplo n.º 1
0
			HttpSocketInputStreamBuffer(
				std::string const & url,
				uint64_t const bufsize, 
				uint64_t const pushbacksize = 0
			) 
			:
				libmaus::network::HttpHeaderWrapper("GET",std::string(),url),
				libmaus::network::HttpBodyWrapper(getHttpHeader().getStream(),getHttpHeader().isChunked(),getHttpHeader().getContentLength()),
				libmaus::network::SocketInputStreamBuffer(getHttpBody(),bufsize,pushbacksize)
			{
			
			}
Ejemplo n.º 2
0
int extractHeaderFields(ICYHeader *header) {
    char metaint[20];
    getHttpHeader(header->buffer, "icy-name", header->icy_name);
    getHttpHeader(header->buffer, "icy-notice1", header->icy_notice1);
    getHttpHeader(header->buffer, "icy-notice2", header->icy_notice2);
    getHttpHeader(header->buffer, "icy-genre", header->icy_genre);
    getHttpHeader(header->buffer, "icy-pub", header->icy_pub);
    getHttpHeader(header->buffer, "icy-br", header->icy_br);
    getHttpHeader(header->buffer, "icy-metaint", metaint);
    header->metaint = atoi(metaint);
    return 0;
}
Ejemplo n.º 3
0
   INT32 restAdaptor::recvRequestBody( pmdRestSession *pSession,
                                       HTTP_PARSE_COMMON &common,
                                       CHAR **ppPath,
                                       INT32 &pathSize )
   {
      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY( SDB__RESTADP_RECVREQBO ) ;
      SDB_ASSERT ( pSession, "pSession is NULL" ) ;
      SDB_ASSERT ( ppPath, "ppPath is NULL" ) ;
      httpConnection *pHttpCon = pSession->getRestConn() ;
      CHAR *pBuffer = NULL ;
      const CHAR *pContentLength = NULL ;
      CHAR *pUrl = NULL ;
      INT32 bodySize = 0 ;
      INT32 sumBodySize = 0 ;
      INT32 curRecvSize  = 0 ;
      INT32 receivedSize = 0 ;
      INT32 tempSize = 0 ;
      INT32 urlSize = 0 ;

      rc = getHttpHeader( pSession, REST_STRING_CONLEN, &pContentLength ) ;
      if ( rc )
      {
         PD_LOG ( PDERROR, "Failed to get http header, rc=%d", rc ) ;
         goto error ;
      }

      if ( pContentLength )
      {
         bodySize = ossAtoi( pContentLength ) ;
         if ( bodySize > 0 )
         {
            if ( bodySize > _maxHttpBodySize )
            {
               rc = SDB_REST_RECV_SIZE ;
               PD_LOG ( PDERROR, "http body size %d greater than %d",
                        bodySize,
                        _maxHttpBodySize ) ;
               goto error ;
            }

            rc = pSession->allocBuff( bodySize + 1,
                                      &(pHttpCon->_pBodyBuf),
                                      sumBodySize ) ;
            if ( rc )
            {
               PD_LOG ( PDERROR, "Unable to allocate %d bytes memory, rc=%d",
                        bodySize, rc ) ;
               goto error ;
            }
            pBuffer = pHttpCon->_pBodyBuf ;
            pBuffer[bodySize] = 0 ;

            if ( pHttpCon->_pPartBody )
            {
               ossMemcpy( pHttpCon->_pBodyBuf,
                          pHttpCon->_pPartBody,
                          pHttpCon->_partSize ) ;
               receivedSize = pHttpCon->_partSize ;
            }

            rc = pSession->recvData( pBuffer + receivedSize,
                                     bodySize - receivedSize,
                                     _timeout,
                                     TRUE,
                                     &curRecvSize,
                                     0 ) ;
            if ( rc )
            {
               PD_LOG ( PDERROR, "Failed to recv, rc=%d", rc ) ;
               goto error ;
            }
            receivedSize += curRecvSize ;

            urlSize = urlDecodeSize( pBuffer, receivedSize ) ;
            rc = pSession->allocBuff( urlSize + 1, &pUrl, tempSize ) ;
            if ( rc )
            {
               PD_LOG ( PDERROR, "Unable to allocate %d bytes memory, rc=%d",
                        urlSize + 1, rc ) ;
               goto error ;
            }
            urlDecode( pBuffer, receivedSize,
                       &pUrl, urlSize ) ;
            pUrl[ urlSize ] = 0 ;
            _parse_http_query( pHttpCon, pUrl, urlSize ) ;
         }
      }

      rc = _convertMsg( pSession, common, ppPath, pathSize ) ;
      if ( rc )
      {
         PD_LOG ( PDERROR, "Failed to build msg, rc=%d", rc ) ;
         goto error ;
      }
      pHttpCon->_common = common ;
   done:
      PD_TRACE_EXITRC( SDB__RESTADP_RECVREQBO, rc ) ;
      return rc ;
   error:
      goto done ;
   }