Skip to content

Instantly share code, notes, and snippets.

@kuniyoshi
Created July 24, 2014 16:17
Show Gist options
  • Save kuniyoshi/c784186f5b76c0bf8c08 to your computer and use it in GitHub Desktop.
Save kuniyoshi/c784186f5b76c0bf8c08 to your computer and use it in GitHub Desktop.
HttpPipe

HttpPipe

SYNOPSIS

  [root@receiver]# curl -v -O https://example.com/upload/
  ...
  Location: https://example.com/upload/XXXXXX
  ...

  [root@sender]# curl -T a_file_to_send_to_reciever https://example.com/upload/XXXXXX

HOW IT WORKS

  1. receiver queries GET to the endpoint URL
  2. server redirects a URL
  3. receiver queries GET the new URL, and wait response
  4. sender queries POST to the URL that is redirect URL
  5. server get data from sender, and pipe it to the receiver
  6. finally sender sends data to receiver with no buffer left

DESCRIPTION

I want to send some files to the other servers, but no local connection between here and other.

Fortunately, both here, and the other can reach Internet. Thus, I usually POST a file my server from here, and GET the file on the other.

This works fine in small times less than one hundred times. I regularly clean up a directory that stores these upload files.

OTHER WAY

This can solve by something, one time URL to GET after POST.

  1. sender POST a file
  2. server save the file
  3. receiver GET the file
  4. server delete the file

But this way has a few bad points.

  • my server always uses 100% of disk volume
  • receiver will wait until sender completes POST
@kuniyoshi
Copy link
Author

at the last line of bad points;
x until
o till

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment