1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT
use crate::ffi;
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// Represents a URI scheme response.
///
/// If you register a particular URI scheme in a #WebKitWebContext,
/// using webkit_web_context_register_uri_scheme(), you have to provide
/// a #WebKitURISchemeRequestCallback. After that, when a URI response
/// is made with that particular scheme, your callback will be
/// called. There you will be able to provide more response parameters
/// when the methods and properties of a #WebKitURISchemeRequest is not
/// enough.
///
/// When you finished setting up your #WebKitURISchemeResponse, call
/// webkit_uri_request_finish_with_response() with it to return the response.
///
/// ## Properties
///
///
/// #### `stream`
/// The input stream to read from.
///
/// Writeable | Construct Only
///
///
/// #### `stream-length`
/// The input stream length in bytes, `-1` for unknown length.
///
/// Writeable | Construct Only
#[doc(alias = "WebKitURISchemeResponse")]
pub struct URISchemeResponse(Object<ffi::WebKitURISchemeResponse, ffi::WebKitURISchemeResponseClass>);
match fn {
type_ => || ffi::webkit_uri_scheme_response_get_type(),
}
}
impl URISchemeResponse {
/// Create a new #WebKitURISchemeResponse
/// ## `input_stream`
/// a #GInputStream to read the contents of the request
/// ## `stream_length`
/// the length of the stream or -1 if not known
///
/// # Returns
///
/// the newly created #WebKitURISchemeResponse.
#[doc(alias = "webkit_uri_scheme_response_new")]
pub fn new(input_stream: &impl IsA<gio::InputStream>, stream_length: i64) -> URISchemeResponse {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::webkit_uri_scheme_response_new(
input_stream.as_ref().to_glib_none().0,
stream_length,
))
}
}
/// Sets the content type for the @self
/// ## `content_type`
/// the content type of the stream
#[doc(alias = "webkit_uri_scheme_response_set_content_type")]
pub fn set_content_type(&self, content_type: &str) {
unsafe {
ffi::webkit_uri_scheme_response_set_content_type(
self.to_glib_none().0,
content_type.to_glib_none().0,
);
}
}
/// Assign the provided #SoupMessageHeaders to the response.
///
/// @headers need to be of the type `SOUP_MESSAGE_HEADERS_RESPONSE`.
/// Any existing headers will be overwritten.
/// ## `headers`
/// the HTTP headers to be set
#[doc(alias = "webkit_uri_scheme_response_set_http_headers")]
pub fn set_http_headers(&self, headers: soup::MessageHeaders) {
unsafe {
ffi::webkit_uri_scheme_response_set_http_headers(
self.to_glib_none().0,
headers.into_glib_ptr(),
);
}
}
/// Sets the status code and reason phrase for the @self.
///
/// If @status_code is a known value and @reason_phrase is [`None`], the @reason_phrase will be set automatically.
/// ## `status_code`
/// the HTTP status code to be returned
/// ## `reason_phrase`
/// a reason phrase
#[doc(alias = "webkit_uri_scheme_response_set_status")]
pub fn set_status(&self, status_code: u32, reason_phrase: Option<&str>) {
unsafe {
ffi::webkit_uri_scheme_response_set_status(
self.to_glib_none().0,
status_code,
reason_phrase.to_glib_none().0,
);
}
}
}