Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Nov 2009

    Unhappy problem with Http response head

    my app uses the symtem http api to visit the http server.
    i used thereal to watch data transfer backgroud.i found that when it visit some url whose response has no 'Content-Type: '
    field,the response data packet as:

    Mon, 02 Nov 2009
    09:58:12 GMT..S
    erver: Apache-Co
    okie: JSESSIONID
    3; Path=/iread..
    Via: HTTP/1.1 mm
    xmp3 (XMS 724Sol
    utions HTG XMP_4
    0_M1_B069 200905
    pt-Ranges: bytes

    but int the function MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent),
    the code

    RStringF contentType = iSession.StringPool().StringF(HTTP::EContentType, RHTTPSession::GetTable());
    THTTPHdrVal contentTypeValue;
    TBuf8<MAX_HTTP_HEAD_DATA_STR_LEN> tbContentType;
    if (responseHeaders.GetField(contentType, 0, contentTypeValue) == KErrNone)
    const TDesC8& tdc8ContentType = contentTypeValue.StrF().DesC();

    this line: responseHeaders.GetField(contentType, 0, contentTypeValue) == KErrNone will be true,
    the value of tdc8ContentType is 'application/octet-stream'.

    it tells that if the http response head has no 'Content-Type: 'field,system will add
    'Content-Type: application/octet-stream' to it automatically.

    and use another function to deal with the RHTTPHeaders

    HBufC8* HttpCacheUtil::HeadersToBufferL(
    RHTTPHeaders& aHttpHeaders,
    RStringPool& aStrP )
    // Get an iterator for the collection of response headers
    HBufC8* headerString = HBufC8::NewL( KMaxHeaderStrLen );
    TPtr8 headerPtr( headerString->Des() );
    TInt newLength( 0 );
    THTTPHdrFieldIter it = aHttpHeaders.Fields();

    while( it.AtEnd() == EFalse )
    TPtrC8 rawData;
    // Get name of next header field
    RStringTokenF fieldName = it();
    RStringF fieldNameStr = aStrP.StringF( fieldName );
    aHttpHeaders.GetRawField( fieldNameStr, rawData );

    newLength+=( fieldNameStr.DesC().Length() + KHttpFieldSeparator().Length() + rawData.Length() +
    KHttpNewLine().Length() );

    if( headerPtr.MaxLength() < newLength )
    // realloc
    HBufC8* temp = HBufC8::New( newLength + KMaxHeaderStrLen );
    if( !temp )
    delete headerString;
    temp->Des().Copy( headerPtr );
    delete headerString;
    headerString = temp;
    headerPtr.Set( headerString->Des() );
    // append
    headerPtr.Append( fieldNameStr.DesC() );
    headerPtr.Append( KHttpFieldSeparator );
    headerPtr.Append( rawData );
    headerPtr.Append( KHttpNewLine );
    //CleanupStack::PushL( headerString );
    return headerString;

    headerString which is the returned String will has SubString 'Content-Type: application/octet-stream' also,
    In my app,the data whose MIME type is 'application/octet-stream' will call the download manager.
    but if there is no 'Content-Type: ' field int the http response head,the data will be dealt with as text.
    i wish when there isn't 'Content-Type: ' field int the http response head,the system won't add 'Content-Type: application/octet-stream'
    to it automatically,let the two function above can't get the 'Content-Type: ',give me some help,please.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Oslo, Norway

    Re: problem with Http response head

    It is the default behaviour suggested by the specs: http://www.w3.org/Protocols/rfc2616/....html#sec7.2.1

Similar Threads

  1. "Forbidden" Response with HTTP Connection
    By bladetech69 in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2009-01-30, 13:39
  2. http filter problem
    By felixksp in forum Symbian
    Replies: 6
    Last Post: 2008-03-11, 10:56
  3. waiting for HTTP POST response
    By gemilib in forum Symbian
    Replies: 3
    Last Post: 2007-11-19, 17:00
  4. Symbian 7.0 UIQ http stack problem
    By Aravindan in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-10-31, 06:06
    By jennieanxa in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2006-09-15, 04:45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts