Re: Bug#139710: first version of https support available
On Tue, 2 Apr 2002, Jason Gunthorpe wrote:
> On Tue, 2 Apr 2002, Tomas Pospisek wrote:
>
> > http: //sourcepole.ch/sources/software/apt_https/
>
> > * how do you like the integration with the rest of your stuff?
>
> Going down the diff..
[...]
>
> +#ifdef WITH_SSL
> +bool CircleBuf::Read(SSL * Ssl)
>
> This is C++. The way to implement this without wacks of #ifdefs everywere
> is to suck a few more things into circlebuf and subclass it for the SSL
> case. The wacks of ifdefs and 'if https's are really excessive.
OK, I have just taken a break after spending roughly 8 hours at it.
Yes it would be nice if it was that easy. The problem is this:
If I subclass CircleBuf (say CircleBufSSL), then everbody who has a
CircleBuf member has to replace it by the CircleBuffSSL version along with
adapting all methods which access CircleBuff to access the *new*
CircleBufferSSL now. Only saying s.th. like:
class ServerStateSSL: public ServerState {
CircleBufferSSL In;
}
where we have some method say:
ServerState::Open() {
[...]
In.Reset();
[...]
}
will not do of course. That means copy-pasting some 95% of the code, then
changing those 10 or so lines that were visible in the patch - which means
completely loosing the ability of the https method to profit from
bugfixes, patches etc. against http. And then it propagates further
and we do not only need CircleBufferSSL, but also ServerStateSSL and
then HttpMethodSSL and since we're at least partly inheriting from all
those classes we need to split off main() into a separate file. It's a
fork and doesn't really have much to do anymore with C++'s idea of
inheritance.
I could have a try basing everything on templates:
class CircleBuf
{
};
class CircleBufSSL : CircleBuf
{
Read(SSL * Ssl);
Write(SSL * Ssl);
};
template <class T>
class ServerState
{
T In;
T Out;
void Read(T bla) { in = bla;};
};
class ServerStateSSL : ServerState<CircleBufSSL>
{
SSL * Ssl;
};
template <class T>
class HttpMethodGen {
ServerState<T> *Server;
bool Go(bool ToFile,ServerState<T> *Srv)
};
typedef HttpMethod HttpMethodGen<CircleBuf>;
class HttpMethodSSL : HttpMethodGen<CircleBufSSL> {
};
HttpMethod Mth;
HttpMethodSSL MthSSL;
main()
{
}
Which is also quite a pain.
-> ???!!!
> + string ProxyStr;
>
> Making 'ProxyStr' a string is silly, it is never assigned to anything but
> a constant.
Well, I have tried out the alternatives: char * and just replacing http
everywhere by:
Https ? "https" : "http"
Both solutions are less readable than string ProxyString, but yes it's
5.3e-7 seconds faster and uses 65 Bytes less memory.
Opinions? Tips? Flames? Bashing?
*t
PS: Please _be aware_ of my other reply as well.
PPS: At least I'm learning ;-)
-----------------------------------------------------------------------
Tomas Pospisek
sourcepole - Linux & Open Source Solutions
http://sourcepole.com
Elestastrasse 18, 7310 Bad Ragaz, Switzerland
Tel:+41 (81) 330 77 13, Fax:+41 (81) 330 77 12
------------------------------------------------------------------------
--
To UNSUBSCRIBE, email to deity-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: