Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'languages.': 0.04; 'subject:Python': 0.06; 'class,': 0.07; 'string': 0.09; 'http': 0.09; 'received:internal': 0.09; 'def': 0.12; 'chris,': 0.16; 'executed,': 0.16; 'name):': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'subject:3.3': 0.16; 'tweak': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'typing': 0.19; 'working.': 0.19; 'written,': 0.19; 'header:User- Agent:1': 0.23; 'source': 0.25; 'post': 0.26; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'am,': 0.29; 'code': 0.31; 'evil': 0.31; 'class': 0.32; 'open': 0.33; 'worked': 0.33; 'skip:_ 10': 0.34; 'received:66': 0.35; 'but': 0.35; 'next': 0.36; 'changing': 0.37; 'so,': 0.37; 'received:10': 0.37; 'sometimes': 0.38; 'thank': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'even': 0.60; 'subject:skip:C 10': 0.61; 'name': 0.63; 'love': 0.65; 'close': 0.67; '20,': 0.68; 'adapted': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=s1network.com; h= message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=mesmtp; bh=n4TFMl3S3PKKlLYfVVqn0m4a ras=; b=Ea74ydLmUBCcgR9+Uxy3+KDn+XfOlg/HLmeiEC26tLt03rlsRgWxy5iU oqfQGHJVUqD9tueFStxs7S/DpdEPa//rCwUMMImAVkhQnEtS899I/IdEBQqeLq+J RMSlovV/6R97BXIbNF//tJFvz6O1gPqgJby0OSIDZYgxlXchKa0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type; s=smtpout; bh=n4TF Ml3S3PKKlLYfVVqn0m4aras=; b=r9VOLuQzma9D7o4E3/a4qi8uMKY0c9YMhVs6 KEmaZi6YbN2mz+aYMApV79p5ONB8vXos+qi+z13loDJj3uZazOmkZWbCCbZJRPrf 8ooqwrhEbzvewRN+zCYRlxxEOlNkt1vxPnr1platO6KcllRfHOy2DHeGRSv97YD0 XuEYyOM= X-Sasl-enc: a6Qh+7wUkXBMAdtAUBNDQBSRvv8zZSPJArDqoA0sp6Av 1384989943 Date: Wed, 20 Nov 2013 18:26:01 -0500 From: Logan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Re: HTTP Header Capitalization in urllib.request.AbstractHTTPHandler (Python 3.3) References: <528C1B1F.2020700@s1network.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------090606040503060106020806" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 116 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384989946 news.xs4all.nl 15986 [2001:888:2000:d::a6]:47603 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60142 This is a multi-part message in MIME format. --------------090606040503060106020806 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 11/20/2013 02:05 AM, Chris Angelico wrote: > On Wed, Nov 20, 2013 at 1:14 PM, Logan wrote: >> Chris, >> >> That is genius. Thank you! > Then it works? Awesome!! (Permit me an evil laugh. Muahahahaaaa!) > > This is why I love working with open source languages. Even if you > don't end up actually changing anything, you can go and snoop the code > and see what happens - sometimes you can tweak your code based on that > knowledge. And hey. This is duck typing at its best! > > ChrisA > Not exactly as written, but close enough to get me working. At one point the following code is executed, turning the value into a string to be "title"d next time it is called: name = name.title() So, I worked around it with the following class, adapted from yours: class CaseSensitiveHeader(object): def __init__(self, name): self.name = name def capitalize(self): return self def title(self): return self def lower(self): return self.name def encode(self, encoding): return self.name.encode(encoding) With that, I am now able to post a case sensitive HTTP header. -- Logan --------------090606040503060106020806 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 11/20/2013 02:05 AM, Chris Angelico wrote:
On Wed, Nov 20, 2013 at 1:14 PM, Logan <logan@s1network.com> wrote:
Chris,

That is genius.  Thank you!
Then it works? Awesome!! (Permit me an evil laugh. Muahahahaaaa!)

This is why I love working with open source languages. Even if you
don't end up actually changing anything, you can go and snoop the code
and see what happens - sometimes you can tweak your code based on that
knowledge. And hey. This is duck typing at its best!

ChrisA

Not exactly as written, but close enough to get me working.  At one point the following code is executed, turning the value into a string to be  "title"d next time it is called:
    name = name.title()

So, I worked around it with the following class, adapted from yours:

class CaseSensitiveHeader(object):
    def __init__(self, name):
        self.name = name

    def capitalize(self):
        return self

    def title(self):
        return self

    def lower(self):
        return self.name

    def encode(self, encoding):
        return self.name.encode(encoding)

With that, I am now able to post a case sensitive HTTP header.

-- Logan
--------------090606040503060106020806--