34a8b28414
due to the usage of a hashmap to store headers, when relaying them to the other side the order was not prevented. even though correct from a standards point-of-view, this caused issues with various programs, and it allows to fingerprint the use of tinyproxy. to implement this, i imported the MIT-licensed hsearch.[ch] from https://github.com/rofl0r/htab which was originally taken from musl libc. it's a simple and efficient hashtable implementation with far better performance characteristic than the one previously used by tinyproxy. additionally it has an API much more well-suited for this purpose. orderedmap.[ch] was implemented from scratch to address this issue. behind the scenes it uses an sblist to store string values, and a htab to store keys and the indices into the sblist. this allows us to iterate linearly over the sblist and then find the corresponding key in the hash table, so the headers can be reproduced in the order they were received. closes #73
40 lines
1.3 KiB
C
40 lines
1.3 KiB
C
/* tinyproxy - A fast light-weight HTTP proxy
|
|
* Copyright (C) 2008 Robert James Kaes <rjk@wormbytes.ca>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*/
|
|
|
|
/* See 'transparent-proxy.c' for detailed information. */
|
|
|
|
#ifndef TINYPROXY_TRANSPARENT_PROXY_H
|
|
#define TINYPROXY_TRANSPARENT_PROXY_H
|
|
|
|
#include "common.h"
|
|
|
|
#ifdef TRANSPARENT_PROXY
|
|
|
|
#include "conns.h"
|
|
#include "orderedmap.h"
|
|
#include "reqs.h"
|
|
|
|
extern int do_transparent_proxy (struct conn_s *connptr,
|
|
orderedmap hashofheaders,
|
|
struct request_s *request,
|
|
struct config_s *config, char **url);
|
|
|
|
#endif
|
|
|
|
#endif
|