[Biopython-dev] [Bug 2824] Bio.Entrez.epost is using an HTTP GET not an HTTP POST

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Thu May 7 09:18:58 UTC 2009


http://bugzilla.open-bio.org/show_bug.cgi?id=2824





------- Comment #1 from biopython-bugzilla at maubp.freeserve.co.uk  2009-05-07 05:18 EST -------
Created an attachment (id=1295)
 --> (http://bugzilla.open-bio.org/attachment.cgi?id=1295&action=view)
Patch for Bio/Entrez/__init__.py

This patch does two things,
(1) Makes Bio.Entrez.epost do an HTTP POST
(2) Catches the too long URL error 414 messages and raises an IOError

Without the patch:

>>> print Entrez.epost("pubmed", id=",".join(str(i) for i in range(1,10000))).read()
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>414 Request-URI Too Large</title>
</head><body>
<h1>Request-URI Too Large</h1>
<p>The requested URL's length exceeds the capacity
limit for this server.<br />
</p>
</body></html>

>>> print Entrez.efetch("pubmed", id=",".join(str(i) for i in range(1,10000)), retmode="text", rettype="uilist").read()
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>414 Request-URI Too Large</title>
</head><body>
<h1>Request-URI Too Large</h1>
<p>The requested URL's length exceeds the capacity
limit for this server.<br />
</p>
</body></html>

Note both the above trigger the Error 414 message, but it does not get caught.

With the patch:

>>> print Entrez.epost("pubmed", id=",".join(str(i) for i in range(1,10000))).read()
<?xml version="1.0"?>
<!DOCTYPE ePostResult PUBLIC "-//NLM//DTD ePostResult, 11 May 2002//EN"
"http://www.ncbi.nlm.nih.gov/entrez/query/DTD/ePost_020511.dtd">
<ePostResult>
        <QueryKey>1</QueryKey>
        <WebEnv>NCID_01_264798363_130.14.18.47_9001_1241687667</WebEnv>
</ePostResult>

>>> print Entrez.efetch("pubmed", id=",".join(str(i) for i in range(1,10000)), retmode="text", rettype="uilist").read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Bio/Entrez/__init__.py", line 126, in efetch
    return _open(cgi, variables)
  File "Bio/Entrez/__init__.py", line 370, in _open
    raise IOError("Requested URL too long (try using EPost?)")
IOError: Requested URL too long (try using EPost?)

Now epost works with long arguments, and using the other tools with too long a
URL will trigger an IOError.


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list