Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Disable keep-alive connections. #70

Merged
merged 1 commit into from
Dec 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Camo is configured through environment variables.
* `CAMO_SOCKET_TIMEOUT`: The maximum number of seconds Camo will wait before giving up on fetching an image. (default: 10)
* `CAMO_TIMING_ALLOW_ORIGIN`: The string for Camo to include in the [`Timing-Allow-Origin` header](http://www.w3.org/TR/resource-timing/#cross-origin-resources) it sends in responses to clients. The header is omitted if this environment variable is not set. (default: not set)
* `CAMO_HOSTNAME`: The `Camo-Host` header value that Camo will send. (default: `unknown`)
* `CAMO_KEEP_ALIVE`: Whether or not to enable keep-alive session. (default: `false`)

## Testing Functionality

Expand Down
5 changes: 5 additions & 0 deletions server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ max_redirects = process.env.CAMO_MAX_REDIRECTS || 4
camo_hostname = process.env.CAMO_HOSTNAME || "unknown"
socket_timeout = process.env.CAMO_SOCKET_TIMEOUT || 10
logging_enabled = process.env.CAMO_LOGGING_ENABLED || "disabled"
keep_alive = process.env.CAMO_KEEP_ALIVE || "false"

content_length_limit = parseInt(process.env.CAMO_LENGTH_LIMIT || 5242880, 10)

accepted_image_mime_types = JSON.parse(Fs.readFileSync(
Expand Down Expand Up @@ -83,6 +85,9 @@ process_url = (url, transferredHeaders, resp, remaining_redirects) ->
path: queryPath
headers: transferredHeaders

if keep_alive == "false"
requestOptions['agent'] = false

srcReq = Protocol.get requestOptions, (srcResp) ->
is_finished = true

Expand Down
9 changes: 7 additions & 2 deletions server.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.