Namespaces
Variants
Actions
Revision as of 07:31, 27 July 2012 by hamishwillee (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Connecting to http using ghttp lib

Jump to: navigation, search
Article Metadata

Article
Created: kamaljaiswal (20 Oct 2007)
Last edited: hamishwillee (27 Jul 2012)

The gHTTP library is designed to be simple and easy to use while still allowing you to get your feet wet at the protocol layer if you have to. You should be able to use the library in your application and never block waiting to send or receive data to/from a remote server

Example

A simple example

/* This is the http request object */
ghttp_request *request = NULL;
 
/* Allocate a new empty request object */
request = ghttp_request_new();
 
/* Set the URI for the request object */
ghttp_set_uri(request, "http://localhost:8080/index.html");
 
/* Close the connection after you are done. */
ghttp_set_header(request, http_hdr_Connection, "close");
 
/* Prepare the connection */
ghttp_prepare(request);
 
/* Process the request */
ghttp_process(request);
 
/* Write out the body.
Note that the body of the request may not be null terminated
so we have to be careful of the length. */

fwrite(ghttp_get_body(request), ghttp_get_body_len(request), 1, stdout);
 
/* Destroy the request.
This closes any file descriptors that may be open and
will free any memory associated with the request. */

ghttp_request_destroy(request);
165 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved