Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60142

Re: Re: HTTP Header Capitalization in urllib.request.AbstractHTTPHandler (Python 3.3)

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 <logan@s1network.com>
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 <logan@s1network.com>
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 <CAPTjJmoZ854_A2gJCBvTJo_7pfgYJ2xD_f9HMauqqp3YWFo8WQ@mail.gmail.com> <528C1B1F.2020700@s1network.com> <CAPTjJmqzki8qaKHo+MtQeRJkentRJOBrLVZB3HRizj3m9tn6KA@mail.gmail.com>
In-Reply-To <CAPTjJmqzki8qaKHo+MtQeRJkentRJOBrLVZB3HRizj3m9tn6KA@mail.gmail.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2992.1384989946.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Re: HTTP Header Capitalization in urllib.request.AbstractHTTPHandler (Python 3.3) Logan <logan@s1network.com> - 2013-11-20 18:26 -0500

csiph-web