1/*
2 * Copyright 2017-2021, Andrew Lindesay <apl@lindesay.co.nz>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5
6#include "LoggingUrlProtocolListener.h"
7
8#include <File.h>
9#include <HttpRequest.h>
10
11#include "Logger.h"
12
13using namespace BPrivate::Network;
14
15
16LoggingUrlProtocolListener::LoggingUrlProtocolListener(
17	BString traceLoggingIdentifier, bool traceLogging)
18	:
19	fTraceLogging(traceLogging),
20	fTraceLoggingIdentifier(traceLoggingIdentifier),
21	fContentLength(0)
22{
23}
24
25
26LoggingUrlProtocolListener::~LoggingUrlProtocolListener()
27{
28}
29
30
31void
32LoggingUrlProtocolListener::BytesWritten(BUrlRequest* caller,
33	size_t bytesWritten)
34{
35	fContentLength += bytesWritten;
36}
37
38
39void
40LoggingUrlProtocolListener::DebugMessage(BUrlRequest* caller,
41	BUrlProtocolDebugMessage type, const char* text)
42{
43	HDTRACE("url->file <%s>; %s", fTraceLoggingIdentifier.String(), text);
44}
45
46
47size_t
48LoggingUrlProtocolListener::ContentLength()
49{
50	return fContentLength;
51}
52