GithubHelp home page GithubHelp logo

Comments (3)

dwmw2 avatar dwmw2 commented on May 4, 2024

This is probably entirely the wrong way to fix it, but it works for me...

diff --git a/libmproxy/utils.py b/libmproxy/utils.py
index 8ac1f54..d22334d 100644
--- a/libmproxy/utils.py
+++ b/libmproxy/utils.py
@@ -190,14 +190,17 @@ class MultiDict:
     _helper = (str,)
     def __init__(self):
         self._d = dict()
+        self._d2 = dict()

     def copy(self):
         m = self.__class__()
         m._d = self._d.copy()
+        m._d2 = self._d2.copy()
         return m

     def clear(self):
-        return self._d.clear()
+        self._d2.clear()
+        return self._d_clear()

     def get(self, key, d=None):
         key = self._helper[0](key)
@@ -212,6 +215,7 @@ class MultiDict:

     def __delitem__(self, key):
         self._d.__delitem__(key)
+        self._d2.__delitem__(key)

     def __getitem__(self, key):
         key = self._helper[0](key)
@@ -220,8 +224,9 @@ class MultiDict:
     def __setitem__(self, key, value):
         if not isSequenceLike(value):
             raise ValueError, "Cannot insert non-sequence."
-        key = self._helper[0](key)
-        return self._d.__setitem__(key, value)
+        hkey = self._helper[0](key)
+        self._d2.__setitem__(hkey, key)
+        return self._d.__setitem__(hkey, value)

     def has_key(self, key):
         key = self._helper[0](key)
@@ -240,6 +245,7 @@ class MultiDict:
         self[key].extend(value)

     def append(self, key, value):
+        key = self._helper[0](key)
         self.extend(key, [value])

     def itemPairs(self):
@@ -276,7 +282,7 @@ class Headers(MultiDict):
         headerElements = []
         for key in sorted(self.keys()):
             for val in self[key]:
-                headerElements.append(key + ": " + val)
+                headerElements.append(self._d2[key] + ": " + val)
         headerElements.append("")
         return "\r\n".join(headerElements)

from mitmproxy.

cortesi avatar cortesi commented on May 4, 2024

Hi,

This has been on my list of things to fix for a while. I've just committed a rewrite of the Headers class that abandons the pretence that we're dealing with a multi-keyed dict. Instead, we store headers as an ordered list of tuples, with dict-like operations working on the list itself. This means that both header order and case is now preserved.

Please take a look and let me know if this works for you.

Cheers,

Aldo

from mitmproxy.

dwmw2 avatar dwmw2 commented on May 4, 2024

Yes, that works fine now; thanks.

from mitmproxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.