×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    6

    Smile Http request/response problem

    Hi guys,

    http client example code its not working properly.THTTP event ie aEvent.iStatus value lessthan zero so it entered default case after that error number like -5120 is displayed on the screen.while i posted url junk char included end of the url like this "http://www.forum.nokia.comÙ}" .pls help me i tried many time but i can't get solution.

    pls reply for this id mrekha01@gmail.com

    here i post my clientengine code:

    // ----------------------------------------------------------------------------
    // CClientEngine::MHFRunL()
    //
    // Inherited from MHTTPTransactionCallback
    // Called by framework to pass transaction events.
    // ----------------------------------------------------------------------------
    void CClientEngine::MHFRunL(RHTTPTransaction aTransaction,
    const THTTPEvent& aEvent)
    {
    switch (aEvent.iStatus)
    {
    case THTTPEvent::EGotResponseHeaders:
    {
    // HTTP response headers have been received. Use
    // aTransaction.Response() to get the response. However, it's not
    // necessary to do anything with the response when this event occurs.

    // Get HTTP status code from header (e.g. 200)
    RHTTPResponse resp = aTransaction.Response();
    TInt status = resp.StatusCode();

    // Get status text (e.g. "OK")
    TBuf<KStatustextBufferSize> statusText;
    statusText.Copy(resp.StatusText().DesC());

    TBuf<KDefaultBufferSize> text;
    _LIT(KHeaderReceived, "Header received. Status: %d %S");
    text.Format(KHeaderReceived, status, &statusText);
    iObserver.ClientEvent(text);
    }
    break;

    case THTTPEvent::EGotResponseBodyData:
    {
    // Part (or all) of response's body data received. Use
    // aTransaction.Response().Body()->GetNextDataPart() to get the actual
    // body data.

    // Get the body data supplier
    MHTTPDataSupplier* body = aTransaction.Response().Body();
    TPtrC8 dataChunk;

    // GetNextDataPart() returns ETrue, if the received part is the last
    // one.
    TBool isLast = body->GetNextDataPart(dataChunk);
    iObserver.ClientBodyReceived(dataChunk);

    TBuf<KInfotextBufferSize> text;
    _LIT(KBodyPartReceived, "%d bytes received... ");
    text.Format(KBodyPartReceived, dataChunk.Length());
    iObserver.ClientEvent(text);

    // NOTE: isLast may not be ETrue even if last data part received.
    // (e.g. multipart response without content length field)
    // Use EResponseComplete to reliably determine when body is completely
    // received.
    if (isLast)
    {
    _LIT(KBodyReceived,"Body received");
    iObserver.ClientEvent(KBodyReceived);
    }

    // Always remember to release the body data.
    body->ReleaseData();
    }
    break;

    case THTTPEvent::EResponseComplete:
    {
    // Indicates that header & body of response is completely received.
    // No further action here needed.
    _LIT(KTransactionComplete, "Transaction Complete");
    iObserver.ClientEvent(KTransactionComplete);
    }
    break;

    case THTTPEvent::ESucceeded:
    {
    // Indicates that transaction succeeded.
    _LIT(KTransactionSuccessful, "Transaction Successful");
    iObserver.ClientEvent(KTransactionSuccessful);

    // Transaction can be closed now. It's not needed anymore.
    aTransaction.Close();
    iRunning = EFalse;
    }
    break;

    case THTTPEvent::EFailed:
    {
    // Transaction completed with failure.
    _LIT(KTransactionFailed, "Transaction Failed");
    iObserver.ClientEvent(KTransactionFailed);
    aTransaction.Close();
    iRunning = EFalse;
    }
    break;

    default:
    // There are more events in THTTPEvent, but they are not usually
    // needed. However, event status smaller than zero should be handled
    // correctly since it's error.
    {
    TBuf<KInfotextBufferSize> text;
    if (aEvent.iStatus < 0)
    {
    _LIT(KErrorStr, "Error: %d");
    text.Format(KErrorStr, aEvent.iStatus);
    // Just close the transaction on errors
    aTransaction.Close();
    iRunning = EFalse;
    }
    else
    {
    // Other events are not errors (e.g. permanent and temporary
    // redirections)
    _LIT(KUnrecognisedEvent, "Unrecognised event: %d");
    text.Format(KUnrecognisedEvent, aEvent.iStatus);
    }
    iObserver.ClientEvent(text);
    }
    break;
    }
    }

  2. #2
    Regular Contributor
    Join Date
    Sep 2006
    Posts
    280

    Re: Http request/response problem

    Hi mrekha01,

    The problem is the DNS Server is not responding as the -5120 error suggests.
    If you are giving www.forum.nokia.com as the url to connect to you are first supposed to resolve the address and then try to connect.

    Regards.

  3. #3
    Regular Contributor
    Join Date
    Jun 2004
    Location
    Helsinki, Finland
    Posts
    69

    Re: Http request/response problem

    I'm not entirely sure what your problem is but it may be that the given url should be "ZeroTerminated". See class TDes16 documentation.

    Here is also a clip from documentation about the error code -5120
    ...
    HttpExampleClient.exe reports error -5120
    This error indicates that the URL cannot be resolved to an IP address. This is usually caused by a problem with DNS; either the location of the DNS server is incorrectly specified or there is no DNS server.

    If using a statically allocated DNS address, check that the value in your comms database's LANService table is correct for your network.
    ...

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    6

    Re: Http request/response problem

    Quote Originally Posted by Tina_Tibrewal
    Hi mrekha01,

    The problem is the DNS Server is not responding as the -5120 error suggests.
    If you are giving www.forum.nokia.com as the url to connect to you are first supposed to resolve the address and then try to connect.

    Regards.

    Thanks Tina_Tibrewal,

    But Still i am facing the same problem.In my emulator not connect with Internet. "No gateway reply" error display when i am checking another Internet related example(default services in emulator) .

    I have changed my DNS server after that the same error -5120 in http client example.

  5. #5
    Regular Contributor
    Join Date
    Jun 2004
    Location
    Helsinki, Finland
    Posts
    69

    Re: Http request/response problem

    Does your emulators browser work correctly? If not, there might be something wrong with your configurations.

Similar Threads

  1. Http request/response problem
    By mrekha01 in forum Symbian
    Replies: 3
    Last Post: 2007-02-01, 17:09
  2. access points problem with HTTP client api
    By Svat_ in forum Symbian
    Replies: 1
    Last Post: 2006-12-26, 16:19
  3. Problem in Http Connection
    By jaceline in forum Mobile Java General
    Replies: 0
    Last Post: 2005-10-14, 04:08
  4. NOKIA vs. SIEMENS HTTP connection problem?
    By imarenic in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2003-11-03, 09:03
  5. Replies: 2
    Last Post: 2003-02-19, 03:10

Posting Permissions

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