473,657 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1360
scott212 <bu*******@gmai l.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 misunderstandin g 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*******@gmai l.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 misunderstandin g 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,newlin e" 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.writ e("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
14595
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 needed). This webpage will call the site's homepage and refresh in 10 seconds. If I can see the homepage then, the site is up, else site is down. I have an example of my code below. My question, is it possible to check the homepage in frame1 (after...
4
1378
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 to/from work. I don't have room on the PDA for all the associated advertising stuff these sites have, so I filter out all but the important text. It's worked a treat until recently when 1 of the sites I read upgraded. When I browsed to it using...
2
8054
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 hang when it tried to load web projects, but after trying to navigate to the http://localhost (or by IP), I saw that it wouldn't ever respond... not even timeout... just keeps waiting for a response. Some info: > I can't access ASP.NET, ASP, HTML,...
2
4148
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 service stopped responding. This is the entry in web.config --- <sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" cookieless="false" timeout="20"/>
4
13177
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 to login (obviously it's using ASPNETDB.mdf). Any ideas? Server Error in '/' Application. --------------------------------------------------------------------------------
2
12153
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 know it's probably a bad idea, but I can't talk my clients out of it ;-) --
1
45161
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 as: (i tried to run the stored procedure on query analyzer, and it works well) Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred...
7
2457
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 the REST based Facebook API - there is a simple example for its usage as shown below: def simple_web_app(request, api_key, secret_key):
18
3239
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, and mostly server 2003. Everyone will have Python 2.5.1 on them, and the script would be running locally. Any ideas?
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.