work towards http transport working for rhizome direct. #9

This commit is contained in:
gardners 2012-09-10 20:22:14 +09:30
parent 872b88f744
commit 4f5f2c2444
3 changed files with 23 additions and 1 deletions

View File

@ -475,6 +475,11 @@ rhizome_direct_sync_request
int rhizome_direct_continue_sync_request(rhizome_direct_sync_request *r); int rhizome_direct_continue_sync_request(rhizome_direct_sync_request *r);
int rhizome_direct_conclude_sync_request(rhizome_direct_sync_request *r); int rhizome_direct_conclude_sync_request(rhizome_direct_sync_request *r);
typedef struct rhizome_direct_transport_state_http {
int port;
char host[1024];
} rhizome_direct_transport_state_http;
void rhizome_direct_http_dispatch(rhizome_direct_sync_request *); void rhizome_direct_http_dispatch(rhizome_direct_sync_request *);
extern unsigned char favicon_bytes[]; extern unsigned char favicon_bytes[];

View File

@ -270,9 +270,22 @@ int app_rhizome_direct_sync(int argc, const char *const *argv,
/* Get iterator capable of 64KB buffering. /* Get iterator capable of 64KB buffering.
In future we should parse the sync URL and base the buffer size on the In future we should parse the sync URL and base the buffer size on the
transport and allowable traffic volumes. */ transport and allowable traffic volumes. */
rhizome_direct_transport_state_http
*state=calloc(sizeof(rhizome_direct_transport_state_http),1);
if (strlen(argv[3])>1020)
{
DEBUG("rhizome direct URI too long");
return -1;
}
if (sscanf(argv[3],"%[^:]:%d",state->host,&state->port)!=2)
{
DEBUG("could not parse rhizome direct URI");
return -1;
}
rhizome_direct_sync_request rhizome_direct_sync_request
*s = rhizome_direct_new_sync_request(rhizome_direct_http_dispatch, *s = rhizome_direct_new_sync_request(rhizome_direct_http_dispatch,
65536,0,mode,NULL); 65536,0,mode,state);
rhizome_direct_start_sync_request(s); rhizome_direct_start_sync_request(s);

View File

@ -480,6 +480,10 @@ int rhizome_direct_parse_http_request(rhizome_http_request *r)
void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r) void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
{ {
DEBUGF("Dispatch size_high=%lld",r->cursor->size_high); DEBUGF("Dispatch size_high=%lld",r->cursor->size_high);
int sock;
/* Warning: tail recursion when done this way. /* Warning: tail recursion when done this way.
Should be triggered by an asynchronous event. Should be triggered by an asynchronous event.