Gearman Server and Client Libraries

Content-Length 0 in HTTP plugin responses

Reported by Máximo Cuadros on 2013-03-08
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
Undecided
Unassigned

Bug Description

The HTTP plugin allways response with a 0 bytes length header instead of the body length as expected.

Regards and thanks.

Example:
$gearmand --http-port 1111 -r http
$ cat /tmp/req
POST /reverse HTTP/1.1
Content-Length: 12

Hello world!

$ netcat localhost 1111 < /tmp/req
HTTP/1.0 200 OK
X-Gearman-Job-Handle: H:mc-air:517
X-Gearman-Command: GEARMAN_COMMAND_WORK_COMPLETE
Content-Length: 0
Server: Gearman/1.1.5

!dlrow olleH

Versions:
gearman: stable 1.1.5
boost: stable 1.53.0 (bottled, HEAD
libevent: stable 2.0.21, HEAD
ossp-uuid: stable 1.6.2

$ uname -a
Darwin mc-air 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

Clint Byrum (clint-fewbar) wrote :

Unable to reproduce on trunk on Ubuntu raring, though its got some other weird effect:

$ telnet localhost 8999
Trying ::1...
Connected to localhost.localdomain.
Escape character is '^]'.
POST /reverse HTTP/1.1
Content-Length: 12

Hello world!
!dlrow olleH OK
X-Gearman-Job-Handle: H:clint-MacBookPro:5
X-Gearman-Command: GEARMAN_COMMAND_WORK_COMPLETE
Content-Length: 12
Server: Gearman/1.1.6

!dlrow olleH

Notice that instead of the appropriate HTTP response code, '200 OK', its the result followed by OK.

Máximo Cuadros (maximo-i) wrote :

My version is 1.1.5 where i can download the trunk version, i cannot find the SVN.

At protocol.cc:217 "content.size()" allways look 0.

I am testing at CentOS release 6.3 (Final) and the same issue with 1.1.5.

Thanks for your fast reply

Máximo Cuadros (maximo-i) wrote :

Its a bit weird i compiled the trunk version too, and i get the same result:
$ telnet localhost 1111
Trying ::1...
Connected to localhost.
Escape character is '^]'.
POST /reverse HTTP/1.1
Content-Length: 12

Hello world!
HTTP/1.0 200 OK
X-Gearman-Job-Handle: H:mc-air:21
X-Gearman-Command: GEARMAN_COMMAND_WORK_COMPLETE
Content-Length: 0
Server: Gearman/1.1.6

!dlrow olleH

This is with the code from: "bzr branch lp:gearmand" compiled with:
./configure --disable-libdrizzle --disable-hiredis --disable-libmemcached --disable-libmysql --disable-libpq --disable-libsqlite3 --disable-option-checking --with-sqlite3=no --with-mysql=no

And the worker code is:
<?php

$gmworker= new GearmanWorker();
$gmworker->addServer('localhost', 4730);
$gmworker->addFunction('reverse', function($job) {
    return strrev($job->workload());
});

print "Waiting for job...\n";
while( $gmworker->work() ) {
    if ($gmworker->returnCode() != GEARMAN_SUCCESS) {
        echo "return_code: " . $gmworker->returnCode() . "\n";
        break;
    }
}

Brian Aker (brianaker) wrote :

Odd... length is used to determine output of the body,... so if it was zero then nothing should print in the body.

Máximo Cuadros (maximo-i) wrote :

Yes then is a issue right? Because gearmand is returning this. :/

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers