[ 
https://issues.apache.org/jira/browse/COUCHDB-2834?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14943677#comment-14943677
 ] 

Nick Vatamaniuc commented on COUCHDB-2834:
------------------------------------------

Python script used for testing.

{code}
import sys, socket
import couchdb

DBNAME='db1'

def setup_db(dbname,user,password,port):
    srv=couchdb.Server('http://%s:%[email protected]:%d'%(user,password,port))
    if dbname in srv:
        print "Deleting previous db",dbname
        srv.delete(dbname)
    return srv.create(dbname)

def get_body():
    return '\r\n'.join([
        '--195044bdf7abd8b23cce7b30d39a19dd',
        'Content-Type: application/json',
        '',
        
'''{"_id":"doc2","_rev":"1-2df9eed63e6f4df24c6a7b593adfc195","_revisions":{"start":1,"ids":["2df9eed63e6f4df24c6a7b593adfc195"]},"_attachments":{"att2":{"content_type":"app/binary","revpos":1,"digest":"md5-3LdAssKDbLEfcH1j5qxmTw==","length":11,"follows":true}}}''',
        '--195044bdf7abd8b23cce7b30d39a19dd',
        'Content-Disposition: attachment; filename="att2"',
        'Content-Type: app/binary',
        'Content-Length: 11',
        '',
        'xxxxxxxxxxx',
        '--195044bdf7abd8b23cce7b30d39a19dd--',
        ])
          
def get_mp_request(dbname,port):
    body = get_body()
    return '\r\n'.join([
        'PUT /%s/doc2?new_edits=false HTTP/1.1'%dbname,
        'Content-Type: multipart/related; 
boundary="195044bdf7abd8b23cce7b30d39a19dd"',
        'Content-Length: %d'%(len(body)),
        'Accept: application/json',
        'Host: 127.0.0.1:%d'%port,
        '',
        body,
        ])

def send_recv(s,data):
    #s.settimeout(2)
    print "-----------------------------------"
    s.sendall(data)
    print "sent data len:",len(data)
    rdata = s.recv(4096)
    print "received",len(rdata),"bytes"
    print >>sys.stderr,rdata
    print "==================================="
    return rdata
    
    
def main(user='adm',password='pass',port=15984):
    dbname = DBNAME
    print "setting up db",DBNAME,"port",port,"auth:",user,password
    setup_db(dbname, user, password, port)
    req = get_mp_request(dbname, port)
    s = socket.socket()
    #raw_input("start wireshark on port "+str(port)+" and then press enter")
    s.connect(('127.0.0.1',port))
    rdata = send_recv(s,req)
    if len(rdata)==0:
        print "received 0 bytes, socket closed"
        return 0
    if 'Connection: close' in rdata:
        return 1
  
    

if __name__=='__main__':
    import argparse
    p = argparse.ArgumentParser()
    p.add_argument('--port',type=int, default=15984)
    p.add_argument('--user', default='adm')
    p.add_argument('--password', default='pass')
    args = p.parse_args()
    sys.exit(main(args.user, args.password, args.port))
{code}

> Server sends connection: close too early
> ----------------------------------------
>
>                 Key: COUCHDB-2834
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-2834
>             Project: CouchDB
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>            Reporter: Nick Vatamaniuc
>
> This is related COUCHDB-2833.
> This was found investigating the failure of replication tests. Specifically 
> couch_replicator_large_atts_tests, the {local, remote} sub-case.
> The test sets up push replications from local to remote.
> Replication workers  have more than 1 document larger than 
> MAX_BULK_ATT_SIZE=64K.  They start pushing them to the target, using a 
> keep-alive connection (default  for HTTP 1.1), the first few pipelined 
> requests will go through using the same connection, then server will accept 
> the first PUT to …/docid?edits=false, then return Connection:close and close 
> the connection after the 201 Created result.  
> Server should not close request too early and instead keep it open longer.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to