Opened 10 years ago

Closed 9 years ago

Last modified 7 years ago

#8094 closed (invalid)

Html button inside html link gives pipe error!!!

Reported by: italomaia Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords: error, html, strange
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Well, this one was pretty much weird bug. For what i know, both requests should work fine.
Clicking in the links below give me different results, with django. The first one works fine, but the second one shouts a broken pipe error.

<a href="url/to/django_view/">See</a>
<a href="url/to/django_view/"><button>See</button></a> <== gives a broken pipe in the console

Using firefox3 plus django svn and ubuntu.

  • To reproduce this error do as following:
  • create a project
  • create a app for it
  • map a url to a view function in the app
  • create the function
  • create a template file with the code above, so that href points to your view through your url mapping.

Voiala!! Broken pipe error.

Change History (9)

comment:1 Changed 10 years ago by Russell Keith-Magee

Resolution: worksforme
Status: newclosed

I can't reproduce this problem. Given that your test case doesn't involve any Django code - both links are standard GET requests as far as Django is concerned - you might want to look somewhere else for the cause of this problem.

comment:2 Changed 10 years ago by italomaia

Well, to reproduce the problem, simply create a link (<a>) that points to a view method. With a button or a image inside. Click in the botton or image and you'll get a broken pipe error in your console.

comment:3 Changed 10 years ago by italomaia

Here goes a nice traceback

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/django/core/servers/", line 278, in run
  File "/usr/lib/python2.5/site-packages/django/core/servers/", line 317, in finish_response
  File "/usr/lib/python2.5/site-packages/django/core/servers/", line 396, in write
  File "/usr/lib/python2.5/site-packages/django/core/servers/", line 460, in send_headers
  File "/usr/lib/python2.5/site-packages/django/core/servers/", line 378, in send_preamble
    'Date: %s\r\n' % http_date()
  File "/usr/lib/python2.5/", line 262, in write
  File "/usr/lib/python2.5/", line 249, in flush
error: (32, 'Broken pipe')

comment:4 in reply to:  2 Changed 10 years ago by Russell Keith-Magee

Replying to italomaia:

Well, to reproduce the problem, simply create a link (<a>) that points to a view method. With a button or a image inside. Click in the botton or image and you'll get a broken pipe error in your console.

That may be what happens on your computer, but it doesn't on mine. I don't know what is going on here, but it isn't as simple as 'button in a link'.

comment:5 Changed 10 years ago by Karen Tracey <kmtracey@…>

Nor mine. I too tried recreating this when it was opened, and could not. Tried the reported Firefox 3 browser and a couple of others. "Broken pipe" means that when the dev server went to send the data for the response, the client browser had already closed its side of the connection. To figure out why you may need to take a network trace to perhaps get a clue what triggered the browser to close its side. From Django's perspective everything was fine until it went to send the response, at which point the client wasn't there to listen.

comment:6 Changed 10 years ago by dfshtsehsdf

For what it's worth, I get a very similar error on OS X with Firefox 3. I first encountered the error trying to embed an image, created by a view, in my template.

comment:7 Changed 9 years ago by SnappyDjangoUser

Resolution: worksforme
Status: closedreopened

I have also seen this broken pipe issue when clicking on a URL that submits data to a form with method POST:

<form method='post' name='search_form'>
    {% for key, value in search_fields.items %}
        <input type="hidden" name="{{ key }}" value="{{ value }}" />
    {% endfor %}

    <a href='url/to/django/view' onClick='document.search_form.submit()'>    <==== Clicking URL gives a broken pipe

I am seeing the same traceback as noted by [08/13/08 14:16:15 changed by italomaia].

I am using Firefox 3.0.4, Ubuntu 8.04 and Django 1.0 official release.

comment:8 Changed 9 years ago by Raphaël Braud

Resolution: invalid
Status: reopenedclosed

Basically, it is an HTML error.

when you write something like :

<a href="url/to/django_view/"><button>See</button></a>


<a href='url/to/django/view' onClick='document.search_form.submit()'>

you're telling the browser to do 2 things in this order :

  • Handle the javascript code (and do POST)
  • Navigate to a new url (and do GET)

Use Firebug or look at Django console logs, you'll see the POST then the GET.
Django will handle the 2 requests without problem but the browser is waiting for 2 threads.

If browser was serializing threads (which is not what threads are made for), you wouldn't see any broken pipe.
But sometimes, the "GET thread" answers before the "POST thread", so the browser considers this is the "thread" to use and "considers" that the "POST thread" is useless, so it closes the connection, thus making Django raise "Broken Pipe".

What you're seeing is just a side-effect of browser thread concurrency.

Try to fix your html code like that :

<a href="javascript:document.search_form.submit();">See</a>

comment:9 Changed 7 years ago by Jacob

milestone: 1.0 beta

Milestone 1.0 beta deleted

Note: See TracTickets for help on using tickets.
Back to Top