473,394 Members | 1,715 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,394 software developers and data experts.

Responding to web request with python

I'm responding with xml to a web request from google checkout but I
think I'm in a catch-22. To get my webserver (apache) to respond I
need a header and then a blank line before my xml begins, or else it
throws the 500 error. If have the blank line before the xml, the
service I'm responding to cannot parse it. If it's a response, can I
still use urllib or something like that? Is that my answer?

Thanks for all your help!
Nov 1 '08 #1
2 1347
scott212 <bu*******@gmail.comwrote:
>
I'm responding with xml to a web request from google checkout but I
think I'm in a catch-22. To get my webserver (apache) to respond I
need a header and then a blank line before my xml begins, or else it
throws the 500 error. If have the blank line before the xml, the
service I'm responding to cannot parse it. If it's a response, can I
still use urllib or something like that? Is that my answer?
You must be misunderstanding something. The HTTP protocol REQUIRES that
the headers and the content be separated by a blank line.

Perhaps you should try to use a debug proxy to intercept the exact text of
the response, just to make sure you're sending what you think you are
sending.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 2 '08 #2
On Sun, 2 Nov 2008, Tim Roberts wrote:
scott212 <bu*******@gmail.comwrote:

I'm responding with xml to a web request from google checkout but I
think I'm in a catch-22. To get my webserver (apache) to respond I
need a header and then a blank line before my xml begins, or else it
throws the 500 error. If have the blank line before the xml, the
service I'm responding to cannot parse it. If it's a response, can I
still use urllib or something like that? Is that my answer?

You must be misunderstanding something. The HTTP protocol REQUIRES that
the headers and the content be separated by a blank line.

Perhaps you should try to use a debug proxy to intercept the exact text of
the response, just to make sure you're sending what you think you are
sending.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
I agree with Tim, check the output. I had the same issue while serving up
GIF images generated on the fly. I was sending two blank lines before the
image data since an extra newline was being automatically added by the
"print" statement.

# Print the header information
print "Content-type: image/gif\n\n"

The above fails since it sends: "header,newline,newline,newline" with the
last newline appended by the print statement. A solution would have been
to simple remove one of the my coded newline characters and let the print
statement add the second one. However, I switched to "write" statements so
I could _see_ the newline characters in my code.

import sys
# Write out the header information
sys.stdout.write("Content-type: image/gif\n\n")

The above worked because "write" does not add an automatic newline
character to the output.

Also, make sure your content-type is correct. The same content would be
handled differently by a browser depending on how it is identified.

"Content-type: text/html" - Sent through the HTML parser then displayed.
"Content-type: text/plain" - Displayed without formatting.

What is the application you're communicating with looking for?

Hope that helps,
Christopher
Nov 3 '08 #3

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

Similar topics

13
by: long5120 | last post by:
I am trying to use webpage with javascript to check if a web server is responding. I was thinking of using 2 frames. Frame1 will have the site, and the Frame2 will be a status bar (not really...
4
by: Ian Mooney | last post by:
I'm using the HttpWebRequest and HttpWebResponse components to automatically scrape content from various internet news sites to store on my iPaq PDA which I later read off-line while commuting...
2
by: AC | last post by:
Running IIS on my WinXP Pro SP1 machine. Haven't installed anything new lately, but suddenly overnight, IIS has stop responding. At first I thought it was Visual Studio.NET 2003 because it would...
2
by: Nils Hedström | last post by:
Today my stateserver (running at the same computer at the web-server) suddenly stopped responding (after 10 days working perfectly). I did not see any entry in the eventlog indicating that the...
4
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying...
2
by: Gregory Piñero | last post by:
Hi Guys, Does anyone know how to program a Python script to send out emails with a request delivery receipt? Is it something I can build into the email message via the mime stuff? And yes, I...
1
by: Ron | last post by:
Hi, I had a stored procedure on SQL 2000 server to run calculation with large amount of data. When I called this stored procedure via System.Data.SqlClient.SqlCommand on production, i got error...
7
by: sami | last post by:
Hi I am trying to write a facebook application in python - I have been programming simple desktop applications till now and am not really familiar with web apps Pyfacebook is the wrapper for...
18
by: rdahlstrom | last post by:
Does anyone know how to determine the window status (Running or Not Responding)? I've tried various methods with no success... This would be on a variety of Windows systems, but all at least XP,...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.