6th September 2006
Sometimes, writing automatic HTML forms processors, you need to post several values with the same name of the form field, e.g.:
collection_gene = str_chrom_name
collection_gene = gene_stable_id
This is against the RFC on form fields design and submitting, but this approach is used – for example, by Ensembl. I spent some time to figure out how to make HTTP_Client and HTTP_Request submit multiple ‘name-value’ pairs instead of one (the latest defined, which overrides the previous). The solution is extremely simple:
Read the rest of this entry »
Posted in Bioinformatics, how-to, PHP, Programming, Science | No Comments »
6th September 2006
If you fetch large amounts of data (e.g. over 2MB per request) using HTTP_Client (or HTTP_request), you may get “out of memory” fatal errors, especially if:
- memory_limit is set to default 8M, and
- you process multiple pages using single non-reset instance of HTTP_Client object.
This problem can manifest itself by producing fatal error after a couple of cycles of successful page retrieval – but always, if run with the same parameters, after some constant or only slightly variable number of cycles.
In my case the problem was that HTTP_Request (a dependancy of HTTP_Client) was holding in memory all the previously fetched pages of the current session (the ‘history’ feature). To force HTTP_Request to hold only the most recent page, you need to ‘disable’ history after creating the HTTP_Client or HTTP_Request object instance:
$req = &new HTTP_Client($params, $headers);
// disable history to save memory
$req->enableHistory(false);
Hope this helps you.
Posted in Bioinformatics, how-to, PHP, Programming, Science | No Comments »
6th September 2006
If you happen to write PHP script, which uses either HTTP_Client or its dependancy HTTP_Request from PEAR, and the script is supposed to work through the HTTP proxy – here are the sample settings you need:
$params['proxy_user'] = 'proxy_username';
$params['proxy_pass'] = 'proxy_password';
$params['proxy_host'] = 'proxy_hostname_or_ip';
$params['proxy_port'] = 8080; // 3128, ...
// I assume $headers were set somewhere else
$req = &new HTTP_Client($params, $headers);
If your proxy does not need authorization – just drop the proxy_user and proxy_pass parameters.
Posted in how-to, PHP, Programming | 1 Comment »