Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

"inappropriate ioctl for device" for XMLHttpRequest call

Something wrong with the request



10:12 pm on Nov 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I have a legacy Mod_perl code that accepts a cxml call. This code is known-good, been around forever. I am trying to create a little JavaScript page that calls this code, for testing (long story).

When I submit the CxmlHttpRequest to the Perl CGI, it is throwing the dreaded "inappropriate ioctl for device" error.

I must need to change something in the JavaScript to make Perl happy. Any ideas?

Here is the JavaScript for the XML request calling Perl:

xmlhttp=new XMLHttpRequest();

xmlhttp.open("POST", "http://www.example.com/path/login.cgi", true);

xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
alert("Response = " + xmlhttp.responseText)

'<?xml version="1.0" encoding="UTF-8"?>'+

Here's the Perl. The read line is throwing the ioctl error. The content length returns a reasonable (non-zero) length.

read(STDIN, $input, $ENV{'CONTENT_LENGTH'}, 0) or $self->std_log("Can't read: $!\n");

$self->std_log("Post method, content length = " . $ENV{'CONTENT_LENGTH'} . "\n" );
$self->std_log("Input = \n $input \n");


10:22 pm on Nov 20, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

parsing POST-parameters yourself is not a good idea, why don't you use CGI.pm or CGI::Minimal if you're concerned about overhead?

Which line throws the error?
What's the std_log method?
I very much doubt that the problem is on the javascript / client-side. Can you log the request with a tool like firefox's live HTTP Header and recreate the request? Can you boil down your mod_perl handler to a simple version that you can post and that still throws the error?
Which version is your kernel, your perl, your apache?


3:29 pm on Nov 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Thanks for the reply.

The read line throws the error.
std_log just writes to a log file with timestamp (works fine).

Regarding parsing the POST parameters, that is certainly correct. But this code was written in 2001 and many paying clients (black boxes to me) connect to it OK. That's why I have find a fix on the client side.

I'll get answers to your questions when I get back to the office. It's Perl 5.8.x, ModPerl 1.x, and the last version of Apache 1 (yes, I know).


4:09 pm on Nov 21, 2010 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

Maybe the Content-Length is not set correctly by the client. Other than that I guess you'll have to log the full request and compare working and non-working ones.

Featured Threads

Hot Threads This Week

Hot Threads This Month