Content-Length 0 in HTTP plugin responses

Bug #1152707 reported by Máximo Cuadros
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
In Progress
High
palik

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

Tags: http

Related branches

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
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;
    }
}

Revision history for this message
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.

Revision history for this message
Máximo Cuadros (maximo-i) wrote :

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

Revision history for this message
palik (1-infe-w) wrote :
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

The patch looks to be stuck in gearmand's current vortex of merge proposals. Hopefully we can un-stick that.

Changed in gearmand:
status: New → In Progress
importance: Undecided → High
assignee: nobody → palik (1-infe-w)
Revision history for this message
palik (1-infe-w) wrote :
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

palik, can we move this over to a github PR?

Revision history for this message
palik (1-infe-w) wrote :

This is already done in git commit f12969e

https://github.com/gearman/gearmand/pull/2/commits/f12969ea7ab028baad17753b22a1e37435464b74

PR 2 solves the issue for POST requests but not for GET. I'll improve libgearman-server/plugins/protocol/http/protocol.cc

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.