send


Description:

public virtual InputStream send (Cancellable? cancellable = null) throws Error

Synchronously requests the URI pointed to by this, and returns a InputStream that can be used to read its contents.

Note that you cannot use this method with Requests attached to a SessionAsync.

Example: Request API, sync:

public static int main (string[] args) {
try {
// Create a session:
Soup.Session session = new Soup.Session ();

// Request a file:
Soup.Request request = session.request ("http://api.valadoc.org/soup-samples/my-secret.txt");
InputStream stream = request.send ();

// Print the content:
DataInputStream data_stream = new DataInputStream (stream);

string? line;
while ((line = data_stream.read_line ()) != null) {
print (line);
print ("\n");
}
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
return 0;
}

valac --pkg libsoup-2.4 request-sync.vala

Parameters:

this

a Request

cancellable

a Cancellable or null

Returns:

a InputStream that can be used to read from the URI pointed to by this.