remove AcceptParser - not needed now, AcceptBaseParser can prepare a table nowmaster
parent
d0d2cfb22c
commit
75daf37bbd
File diff suppressed because one or more lines are too long
@ -1,124 +0,0 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is distributed under the 2-Clause BSD licence.
|
||||
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_acceptparser
|
||||
#define headerfile_winix_core_acceptparser
|
||||
|
||||
#include "utils/acceptbaseparser.h"
|
||||
#include "log.h"
|
||||
#include "header.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
|
||||
|
||||
|
||||
class AcceptParser : public AcceptBaseParser
|
||||
{
|
||||
public:
|
||||
|
||||
static constexpr size_t MAX_CONTAINER_LENGTH = 16;
|
||||
|
||||
/*
|
||||
* IMPROVEME add support for something like "text/html;level=1" (skip the level part)
|
||||
*
|
||||
* https://developer.mozilla.org/en-US/docs/Glossary/Quality_values
|
||||
* Some syntax, like the one of Accept, allow additional specifiers like text/html;level=1.
|
||||
* These increase the specificity of the value. Their use is extremely rare.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
void Parse(const wchar_t * str, std::vector<HeaderValue> & header_values, bool clear_header_values = true)
|
||||
{
|
||||
if( clear_header_values )
|
||||
header_values.clear();
|
||||
|
||||
this->header_values = &header_values;
|
||||
AcceptBaseParser::parse(str);
|
||||
|
||||
std::sort(header_values.begin(), header_values.end(), [](HeaderValue & h1, HeaderValue & h2) -> bool {
|
||||
return h1.weight > h2.weight;
|
||||
});
|
||||
|
||||
PutToLog(header_values);
|
||||
}
|
||||
|
||||
|
||||
void Parse(const std::wstring & str, std::vector<HeaderValue> & header_values, bool clear_header_values = true)
|
||||
{
|
||||
Parse(str.c_str(), header_values, clear_header_values);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::vector<HeaderValue> * header_values;
|
||||
|
||||
void Param(const std::wstring & param, double q)
|
||||
{
|
||||
if( header_values->size() < MAX_CONTAINER_LENGTH && q > 0.0 )
|
||||
{
|
||||
if( q > 1.0 )
|
||||
q = 1.0;
|
||||
|
||||
header_values->resize(header_values->size() + 1);
|
||||
header_values->back().value = param;
|
||||
header_values->back().weight = q;
|
||||
}
|
||||
}
|
||||
|
||||
void PutToLog(std::vector<HeaderValue> & header_values)
|
||||
{
|
||||
if( !header_values.empty() )
|
||||
{
|
||||
log << log3 << "AP: " << Header::accept << " header consists of: ";
|
||||
HeaderValue::log_values(header_values, log);
|
||||
log << logend;
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log3 << "AP: there is no " << Header::accept << " header" << logend;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
|
||||
#endif
|
@ -1,3 +1,53 @@
|
||||
# DO NOT DELETE
|
||||
|
||||
acceptbaseparser.o: acceptbaseparser.h ../../../tito/src/misc.h
|
||||
acceptbaseparser.o: acceptbaseparser.h ../../../winix/winixd/core/header.h
|
||||
acceptbaseparser.o: ../../../winix/winixd/core/log.h
|
||||
acceptbaseparser.o: ../../../winix/winixd/core/logmanipulators.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/log/log.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/textstream/textstream.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/textstream/stream.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/space/space.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/textstream/types.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/inttostr.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/utf8/utf8.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/textstream/stream.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/utf8/utf8_templates.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/utf8/utf8_private.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/date/date.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/membuffer/membuffer.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/textstream/types.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/log/filelog.h
|
||||
acceptbaseparser.o: ../../../morm/src/morm.h ../../../morm/src/morm_types.h
|
||||
acceptbaseparser.o: ../../../morm/src/model.h
|
||||
acceptbaseparser.o: ../../../morm/src/modelconnector.h
|
||||
acceptbaseparser.o: ../../../morm/src/clearer.h
|
||||
acceptbaseparser.o: ../../../morm/src/dbconnector.h
|
||||
acceptbaseparser.o: ../../../morm/src/queryresult.h ../../../morm/src/ft.h
|
||||
acceptbaseparser.o: ../../../morm/src/flatconnector.h
|
||||
acceptbaseparser.o: ../../../morm/src/dbexpression.h
|
||||
acceptbaseparser.o: ../../../morm/src/baseexpression.h
|
||||
acceptbaseparser.o: ../../../morm/src/modelenv.h
|
||||
acceptbaseparser.o: ../../../morm/src/modeldata.h
|
||||
acceptbaseparser.o: ../../../morm/src/cursorhelper.h
|
||||
acceptbaseparser.o: ../../../morm/src/finderhelper.h
|
||||
acceptbaseparser.o: ../../../morm/src/fieldvaluehelper.h
|
||||
acceptbaseparser.o: ../../../morm/src/wrapper.h
|
||||
acceptbaseparser.o: ../../../morm/src/spacewrapper.h
|
||||
acceptbaseparser.o: ../../../morm/src/baseobjectwrapper.h
|
||||
acceptbaseparser.o: ../../../morm/src/modelcontainerwrapper.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/text.h
|
||||
acceptbaseparser.o: ../../../morm/src/flatexpression.h
|
||||
acceptbaseparser.o: ../../../morm/src/finder.h ../../../morm/src/cursor.h
|
||||
acceptbaseparser.o: ../../../morm/src/jsonexpression.h
|
||||
acceptbaseparser.o: ../../../morm/src/postgresqlexpression.h
|
||||
acceptbaseparser.o: ../../../morm/src/jsonconnector.h
|
||||
acceptbaseparser.o: ../../../morm/src/postgresqlconnector.h
|
||||
acceptbaseparser.o: ../../../morm/src/postgresqlqueryresult.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/convert.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/inttostr.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/patternreplacer.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/strtoint.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/text.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/misc.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/utf8/utf8_stream.h
|
||||
acceptbaseparser.o: ../../../pikotools/src/convert/double.h
|
||||
|
Loading…
Reference in new issue