output/httpd/client: eliminate GLib
This commit is contained in:
parent
7c5396ffb9
commit
6d9739165e
@ -26,8 +26,6 @@
|
|||||||
#include "system/SocketError.hxx"
|
#include "system/SocketError.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -142,7 +140,9 @@ HttpdClient::HandleLine(const char *line)
|
|||||||
bool
|
bool
|
||||||
HttpdClient::SendResponse()
|
HttpdClient::SendResponse()
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024], *allocated = nullptr;
|
||||||
|
const char *response;
|
||||||
|
|
||||||
assert(state == RESPONSE);
|
assert(state == RESPONSE);
|
||||||
|
|
||||||
if (dlna_streaming_requested) {
|
if (dlna_streaming_requested) {
|
||||||
@ -158,18 +158,14 @@ HttpdClient::SendResponse()
|
|||||||
"contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n"
|
"contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n"
|
||||||
"\r\n",
|
"\r\n",
|
||||||
httpd.content_type);
|
httpd.content_type);
|
||||||
|
response = buffer;
|
||||||
|
|
||||||
} else if (metadata_requested) {
|
} else if (metadata_requested) {
|
||||||
char *metadata_header =
|
response = allocated =
|
||||||
icy_server_metadata_header(httpd.name, httpd.genre,
|
icy_server_metadata_header(httpd.name, httpd.genre,
|
||||||
httpd.website,
|
httpd.website,
|
||||||
httpd.content_type,
|
httpd.content_type,
|
||||||
metaint);
|
metaint);
|
||||||
|
|
||||||
g_strlcpy(buffer, metadata_header, sizeof(buffer));
|
|
||||||
|
|
||||||
delete[] metadata_header;
|
|
||||||
|
|
||||||
} else { /* revert to a normal HTTP request */
|
} else { /* revert to a normal HTTP request */
|
||||||
snprintf(buffer, sizeof(buffer),
|
snprintf(buffer, sizeof(buffer),
|
||||||
"HTTP/1.1 200 OK\r\n"
|
"HTTP/1.1 200 OK\r\n"
|
||||||
@ -179,9 +175,11 @@ HttpdClient::SendResponse()
|
|||||||
"Cache-Control: no-cache, no-store\r\n"
|
"Cache-Control: no-cache, no-store\r\n"
|
||||||
"\r\n",
|
"\r\n",
|
||||||
httpd.content_type);
|
httpd.content_type);
|
||||||
|
response = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t nbytes = SocketMonitor::Write(buffer, strlen(buffer));
|
ssize_t nbytes = SocketMonitor::Write(response, strlen(response));
|
||||||
|
delete[] allocated;
|
||||||
if (gcc_unlikely(nbytes < 0)) {
|
if (gcc_unlikely(nbytes < 0)) {
|
||||||
const SocketErrorMessage msg;
|
const SocketErrorMessage msg;
|
||||||
FormatWarning(httpd_output_domain,
|
FormatWarning(httpd_output_domain,
|
||||||
@ -321,7 +319,7 @@ HttpdClient::TryWrite()
|
|||||||
metadata_sent = true;
|
metadata_sent = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
guchar empty_data = 0;
|
char empty_data = 0;
|
||||||
|
|
||||||
ssize_t nbytes = Write(&empty_data, 1);
|
ssize_t nbytes = Write(&empty_data, 1);
|
||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
@ -406,13 +404,13 @@ HttpdClient::PushPage(Page *page)
|
|||||||
void
|
void
|
||||||
HttpdClient::PushMetaData(Page *page)
|
HttpdClient::PushMetaData(Page *page)
|
||||||
{
|
{
|
||||||
|
assert(page != nullptr);
|
||||||
|
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
metadata->Unref();
|
metadata->Unref();
|
||||||
metadata = nullptr;
|
metadata = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_return_if_fail (page);
|
|
||||||
|
|
||||||
page->Ref();
|
page->Ref();
|
||||||
metadata = page;
|
metadata = page;
|
||||||
metadata_sent = false;
|
metadata_sent = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user