473,383 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How can I determine an HTTPMessage ?

Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.

Jan 11 '06 #1
13 2756
Kevin wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.


I think you're missing most of the context and detail that would help us
provide a useful answer for you.

Think about it from a reader's point of view. We don't know what
packages you are using, we don't know what you mean by "HTTPMessage" (is
it a specific class, or is it just how you refer to the more generic
"HTTP message" entity?), we don't know what version of anything you are
using or what platform you're on.

-Peter

Jan 11 '06 #2
Kevin wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.

I was thinking of a number between one and a thousand, and I forgot it.
Could someone please remind me what it was?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 11 '06 #3
Steve Holden wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.


I was thinking of a number between one and a thousand, and I forgot it.
Could someone please remind me what it was?


204.

</F>

Jan 11 '06 #4
Steve Holden <st***@holdenweb.com> writes:
Kevin wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.

I was thinking of a number between one and a thousand, and I forgot it. Could
someone please remind me what it was?


3.14159265352....

--
Jorge Godoy <go***@ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Jan 11 '06 #5
Steve Holden schrieb:
Kevin wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.

I was thinking of a number between one and a thousand, and I forgot it.
Could someone please remind me what it was?


import smtplib

server = smtplib.SMTP('your.favorite.smtp.relay')

msg = """From: Spambot
To: py*********@python.org

Hi!
is it %d?
"""

for i in range(1, 1001):
server.sendmail('Spambot', 'py*********@python.org', msg % i)

server.quit()

# could it be considered dangerous to post such code? ;)

--
David.
Jan 11 '06 #6
Fredrik Lundh wrote:
Steve Holden wrote:

Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.


I was thinking of a number between one and a thousand, and I forgot it.
Could someone please remind me what it was?

204.

Thanks. This is *such* a helpful group. I'll write it down this time.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 11 '06 #7
Steve Holden wrote:
Fredrik Lundh wrote:
Steve Holden wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.

I was thinking of a number between one and a thousand, and I forgot it.
Could someone please remind me what it was?


204.


Thanks. This is *such* a helpful group. I'll write it down this time.


Anticipating the next such incident, I borrowed the time machine and put
the answer on a web site for you for when you know the question:

http://random.org/cgi-bin/randnum?num=1&max=1000

No need to thank me now either -- I bumped into you while I was there
and you have will-been thanked me then. (I also bought you a beer, so
now you owe me one.)

Cheers,
-Peter

Jan 11 '06 #8
Steve Holden wrote:
I was thinking of a number between one and a thousand, and I forgot it.
Could someone please remind me what it was?


204.

Thanks. This is *such* a helpful group. I'll write it down this time.


or you can look it up in the HTTP specification the next time you
need it.

</F>

Jan 11 '06 #9
Peter Hansen wrote:
Kevin wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.


I think you're missing most of the context and detail that would help us
provide a useful answer for you.


Here's some of your own medicine. ;-)

A Google search for "HTTPMessage Python" produced a link to the
surprisingly helpful "urllib2 - The Missing Manual" [1]. This states
that the result of urlopen can be queried using the info method; for
example:

import urllib2
try:
f = urllib2.urlopen(some_url)
message = f.info()
except urllib2.HTTPError, exc:
message = exc.info()

One would guess that the status attribute on the above message object
would yield some kind of descriptive response from the server, noting
that the response code from the server is itself typically found as the
code attribute on either the f or exc objects manipulated in the above
example. However, my limited experiments show that status is typically
set to the empty string, although a perusal of the source code for
httplib reveals that the status attribute is only used to signal
exceptional conditions in the processing of responses, and I would
guess that most HTTP interactions wouldn't result in anything special
being put in that attribute.

I suppose what one could do is to examine f.code or exc.code and then
interpret that value accordingly (see the httplib module for the HTTP
response code constants) possibly generating a suitable message,
although the only place in the standard library that helps here is the
BaseHTTPRequestHandler class:

import BaseHTTPServer
message, description = \
BaseHTTPServer.BaseHTTPRequestHandler.responses[f.code]

Paul

P.S. It's a shame that the time spent by various other contributors in
making unhelpful remarks in response to the original, albeit imprecise
query wasn't spent in offering just a little helpful advice instead. I
guess such horseplay is how the Python community gets its "arrogant"
label...

[1] http://www.voidspace.org.uk/python/a.../urllib2.shtml

Jan 11 '06 #10
Paul Boddie wrote:
Peter Hansen wrote:
Kevin wrote:
Can you tell me what to look for in an HTTPMessage that is an error? I
have looked at the header objects and I cannot determine an error
message.


I think you're missing most of the context and detail that would help us
provide a useful answer for you.


Here's some of your own medicine. ;-)

A Google search for "HTTPMessage Python" produced a link to the


A reasonable search to do, but one which might well have resulted in
lots of work that was completely off base. It seemed quite possible to
me that the OP, clearly not experienced in this area, was simply
referring to an "HTTP message", and I try not to spend lots of time on
potentially wild goose chases when a simple request for more info could
produce the certainty needed to avoid lots of guessing. (Plus, arrogant
though it might be, I feel that being direct and public about the need
for proper background info, true replicas of error tracebacks, platform
info, etc, may actually help reduce the recent apparent surge in folks
who seem to be new to support forums and the etiquette thereof. I know,
it's probably a lost cause, but I'm still an idealist.)

It will be interesting to see how accurately you've guessed at what the
OP needed. My hat's off to you in advance if you hit the nail on the
head...

-Peter

Jan 12 '06 #11
EP
if you bought him a beer in the future he would owe you less than a
beer today due to the time value of beer (which is, amazingly, much
greater than the time value of money) If he buys you a beer today, you
will need to go back to the future, and we must all hope this equation
converges on an cross-time equilibrium when dealing only in integer
beers. ("call me XAH!")

....

in case the OP was looking for HTTP codes, there is a list here (among
many other places) http://paradigmb.com/httpCodes.txt.

now the OP may ask "How do I determine the HTTP response code when I am
using the urllib2 module such as in the following code: ..."

but we will wait for that question (I propose) so as not to force the
OP into serious future-beer debt.

EP

Jan 12 '06 #12
Peter Hansen wrote:
Steve Holden wrote:
Fredrik Lundh wrote:
Steve Holden wrote:

>Can you tell me what to look for in an HTTPMessage that is an error? I
>have looked at the header objects and I cannot determine an error
>message.

I was thinking of a number between one and a thousand, and I forgot it.
Could someone please remind me what it was?

204.


Thanks. This is *such* a helpful group. I'll write it down this time.

Anticipating the next such incident, I borrowed the time machine and put
the answer on a web site for you for when you know the question:

http://random.org/cgi-bin/randnum?num=1&max=1000

No need to thank me now either -- I bumped into you while I was there
and you have will-been thanked me then. (I also bought you a beer, so
now you owe me one.)


Your memory's getting terrible, Peter. I will have bought you three
beers the day before you will have bought me that one. Anyway, "*now*
you owe me one" is clearly wrong: "*then* you owe me one" should
actually have been "*then* I'll only owe you two".

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 12 '06 #13
Thanks, I was trying to get it to work with urllib instead of urllib2.
The code below works. Thanks.

import urllib2 as myurl

url = "some url"

try:
myurl.urlopen(url)
print "Redirecting to %s\n" % url
return url
except:
print "An invalid login_query was specified. Redirecting to
prefedit.psp with an error message.\n"
return "prefedit.psp?uname=%s&err=Invalid%%20login%%20que ry."
%(username)

Jan 19 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nathan Sokalski | last post by:
I want to determine the operating system using ASP (or VBScript inside of ASP). I tried to get it using the Request. ServerVariables(EnvironmentVariable) method. On the web page about ASP in which...
3
by: Shahid Juma | last post by:
Hello All, This may be a trivial question, but I was wondering how can you determine if a value contains an Integer or Float. I know there is a function called IsNumeric, however you can't...
5
by: Hennie de Nooijer | last post by:
Hi, This is a diffcult issue to explain. I hope to make my problem clear to you. SITUATION I'm building A SLA Query for a customer. This customer has an awkward way to determine the SLA results...
3
by: lucpustjens | last post by:
Hello, I want te determine the client operating system, because I need to kno the default cookie directory. If there is a way to determine the cooki directory directly, than it is also good. ...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
9
by: Adam | last post by:
Can someone please help!! I am trying to figure out what a font is? Assume I am working with a fixed font say Courier 10 point font Question 1: What does this mean 10 point font Question 2:...
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
6
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.