httpimagestore 1.8.1 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +7 -7
  3. data/Gemfile.lock +20 -20
  4. data/README.md +165 -37
  5. data/Rakefile +7 -2
  6. data/VERSION +1 -1
  7. data/bin/httpimagestore +74 -41
  8. data/lib/httpimagestore/configuration/file.rb +20 -11
  9. data/lib/httpimagestore/configuration/handler.rb +96 -257
  10. data/lib/httpimagestore/configuration/handler/source_store_base.rb +37 -0
  11. data/lib/httpimagestore/configuration/handler/statement.rb +114 -0
  12. data/lib/httpimagestore/configuration/identify.rb +17 -9
  13. data/lib/httpimagestore/configuration/output.rb +33 -61
  14. data/lib/httpimagestore/configuration/path.rb +2 -2
  15. data/lib/httpimagestore/configuration/request_state.rb +131 -0
  16. data/lib/httpimagestore/configuration/s3.rb +41 -29
  17. data/lib/httpimagestore/configuration/thumbnailer.rb +189 -96
  18. data/lib/httpimagestore/configuration/validate_hmac.rb +170 -0
  19. data/lib/httpimagestore/error_reporter.rb +6 -1
  20. data/lib/httpimagestore/ruby_string_template.rb +10 -19
  21. metadata +40 -102
  22. data/.rspec +0 -1
  23. data/features/cache-control.feature +0 -41
  24. data/features/compatibility.feature +0 -165
  25. data/features/data-uri.feature +0 -55
  26. data/features/encoding.feature +0 -103
  27. data/features/error-reporting.feature +0 -281
  28. data/features/flexi.feature +0 -259
  29. data/features/health-check.feature +0 -29
  30. data/features/request-matching.feature +0 -211
  31. data/features/rewrite.feature +0 -122
  32. data/features/s3-store-and-thumbnail.feature +0 -82
  33. data/features/source-failover.feature +0 -71
  34. data/features/step_definitions/httpimagestore_steps.rb +0 -203
  35. data/features/storage.feature +0 -198
  36. data/features/support/env.rb +0 -116
  37. data/features/support/test-large.jpg +0 -0
  38. data/features/support/test.empty +0 -0
  39. data/features/support/test.jpg +0 -0
  40. data/features/support/test.png +0 -0
  41. data/features/support/test.txt +0 -1
  42. data/features/support/tiny.png +0 -0
  43. data/features/xid-forwarding.feature +0 -49
  44. data/httpimagestore.gemspec +0 -145
  45. data/load_test/load_test.1k.23a022f6e.m1.small-comp.csv +0 -3
  46. data/load_test/load_test.1k.ec9bde794.m1.small.csv +0 -4
  47. data/load_test/load_test.jmx +0 -317
  48. data/load_test/thumbnail_specs.csv +0 -11
  49. data/load_test/thumbnail_specs_v2.csv +0 -10
  50. data/spec/configuration_file_spec.rb +0 -333
  51. data/spec/configuration_handler_spec.rb +0 -255
  52. data/spec/configuration_identify_spec.rb +0 -67
  53. data/spec/configuration_output_spec.rb +0 -821
  54. data/spec/configuration_path_spec.rb +0 -138
  55. data/spec/configuration_s3_spec.rb +0 -911
  56. data/spec/configuration_source_failover_spec.rb +0 -101
  57. data/spec/configuration_spec.rb +0 -90
  58. data/spec/configuration_thumbnailer_spec.rb +0 -483
  59. data/spec/ruby_string_template_spec.rb +0 -61
  60. data/spec/spec_helper.rb +0 -89
  61. data/spec/support/compute.jpg +0 -0
  62. data/spec/support/cuba_response_env.rb +0 -40
  63. data/spec/support/full.cfg +0 -183
  64. data/spec/support/utf_string.txt +0 -1
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWExYjg5NWQ2ZjU4MDVlN2RhYmRiYWUxNDFiYTVhMmNmMzYwNGNiMw==
5
+ data.tar.gz: !binary |-
6
+ NDc4YmY4NjE1ZWNiNDgzNDlkZTE4MjA2NjEzYjcxYTE4ZmU1ODU3Nw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MzY4MjVlNTY4YjI0ZmM1M2I0OTg1NDM2ODI3YmQxMTczYzEyNWJhMjZlMDE0
10
+ ZmVmNjc1YTMwY2JjZjY0Njk2MWVhMGU1OTY0MDA0ZjU1NGRkMDYyZGQ5ZjRj
11
+ NTM0MDRlM2YwMDAxZjg5NGVmMmU0YmRjMTA0NWQ5YWI0M2FlYTc=
12
+ data.tar.gz: !binary |-
13
+ ZGE1ZGY1NWZiYzE0OWY3NmU1NzM3NTUxNTYyYmY0MDJjMTAxMGRlNGZjODdk
14
+ ZTBjY2Y5OTZiNzg3ODc5NTEwZDExZTRhMGE1ZjgyNmJlZmY3YmQ0NzViYjM0
15
+ NjQ3NzgyOTZmZTQxZWIzOWU4M2RiYTlmYTk2ZjUzOGQ2YjI4M2I=
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source 'http://rubygems.org'
2
2
  ruby '1.9.3'
3
3
 
4
- gem 'unicorn-cuba-base', '~> 1.2.2'
4
+ gem 'unicorn-cuba-base', '~> 1.6'
5
5
  #gem 'unicorn-cuba-base', path: '../unicorn-cuba-base'
6
- gem 'httpthumbnailer-client', '~> 1.2.0'
6
+ gem 'httpthumbnailer-client', '~> 1.3'
7
7
  #gem 'httpthumbnailer-client', path: '../httpthumbnailer-client'
8
8
  gem 'aws-sdk', '~> 1.10'
9
- gem 'mime-types', '~> 1.17'
9
+ gem 'mime-types', '~> 2.6', '< 2.99'
10
10
  gem 'sdl4r', '~> 0.9'
11
11
  gem 'msgpack', '~> 0.5'
12
12
  gem 'addressable', '~> 2.3'
@@ -14,14 +14,14 @@ gem 'addressable', '~> 2.3'
14
14
  # Add dependencies to develop your gem here.
15
15
  # Include everything needed to run rake, tests, features, etc.
16
16
  group :development do
17
- gem 'faraday', '>= 0.8'
17
+ gem 'faraday', '~> 0.8'
18
18
  gem 'rspec', '~> 2.13'
19
- gem 'cucumber', '>= 0'
20
- gem 'jeweler', '~> 1.8.4'
19
+ gem 'cucumber', '~> 1.3'
20
+ gem "jeweler", "~> 1.8", ">= 1.8.8"
21
21
  gem 'rdoc', '~> 3.9'
22
22
  gem 'daemon', '~> 1'
23
23
  gem 'prawn', '= 0.8.4'
24
24
  #gem 'httpthumbnailer', path: '../httpthumbnailer'
25
- gem 'httpthumbnailer', '~> 1.2.0'
25
+ gem 'httpthumbnailer', '~> 1.3'
26
26
  end
27
27
 
@@ -8,7 +8,7 @@ GEM
8
8
  uuidtools (~> 2.1)
9
9
  builder (3.2.2)
10
10
  cli (1.3.1)
11
- cuba (3.3.0)
11
+ cuba (3.4.0)
12
12
  rack
13
13
  cucumber (1.3.8)
14
14
  builder (>= 2.1.2)
@@ -18,7 +18,7 @@ GEM
18
18
  multi_test (>= 0.0.2)
19
19
  daemon (1.1.0)
20
20
  diff-lcs (1.2.4)
21
- facter (1.6.18)
21
+ facter (1.7.6)
22
22
  faraday (0.8.8)
23
23
  multipart-post (~> 1.2.0)
24
24
  gherkin (2.12.1)
@@ -34,11 +34,11 @@ GEM
34
34
  hashie (2.0.5)
35
35
  highline (1.6.20)
36
36
  httpauth (0.2.0)
37
- httpclient (2.4.0)
38
- httpthumbnailer (1.2.0)
37
+ httpclient (2.6.0.1)
38
+ httpthumbnailer (1.3.0)
39
39
  rmagick (~> 2)
40
- unicorn-cuba-base
41
- httpthumbnailer-client (1.2.0)
40
+ unicorn-cuba-base (~> 1.6.0)
41
+ httpthumbnailer-client (1.3.0)
42
42
  cli (~> 1.3)
43
43
  httpclient (>= 2.3)
44
44
  multipart-parser (~> 0.1.1)
@@ -54,8 +54,8 @@ GEM
54
54
  json (1.8.1)
55
55
  jwt (0.1.8)
56
56
  multi_json (>= 1.5)
57
- kgio (2.9.2)
58
- mime-types (1.25)
57
+ kgio (2.9.3)
58
+ mime-types (2.6.1)
59
59
  msgpack (0.5.5)
60
60
  multi_json (1.8.2)
61
61
  multi_test (0.0.2)
@@ -77,7 +77,7 @@ GEM
77
77
  prawn-core (0.8.4)
78
78
  prawn-layout (0.8.4)
79
79
  prawn-security (0.8.4)
80
- rack (1.5.2)
80
+ rack (1.6.1)
81
81
  raindrops (0.13.0)
82
82
  rake (10.1.0)
83
83
  rdoc (3.12.2)
@@ -93,17 +93,17 @@ GEM
93
93
  rspec-mocks (2.14.3)
94
94
  ruby-ip (0.9.3)
95
95
  sdl4r (0.9.11)
96
- unicorn (4.8.3)
96
+ unicorn (4.6.3)
97
97
  kgio (~> 2.6)
98
98
  rack
99
99
  raindrops (~> 0.7)
100
- unicorn-cuba-base (1.2.2)
100
+ unicorn-cuba-base (1.6.0)
101
101
  cli (~> 1.3)
102
102
  cuba (~> 3.0)
103
- facter (~> 1.6.11)
103
+ facter (~> 1.6, >= 1.6.18)
104
104
  raindrops (~> 0.11)
105
105
  ruby-ip (~> 0.9)
106
- unicorn (>= 4.6.2)
106
+ unicorn (~> 4.6.2)
107
107
  uuidtools (2.1.4)
108
108
 
109
109
  PLATFORMS
@@ -112,16 +112,16 @@ PLATFORMS
112
112
  DEPENDENCIES
113
113
  addressable (~> 2.3)
114
114
  aws-sdk (~> 1.10)
115
- cucumber
115
+ cucumber (~> 1.3)
116
116
  daemon (~> 1)
117
- faraday (>= 0.8)
118
- httpthumbnailer (~> 1.2.0)
119
- httpthumbnailer-client (~> 1.2.0)
120
- jeweler (~> 1.8.4)
121
- mime-types (~> 1.17)
117
+ faraday (~> 0.8)
118
+ httpthumbnailer (~> 1.3)
119
+ httpthumbnailer-client (~> 1.3)
120
+ jeweler (~> 1.8, >= 1.8.8)
121
+ mime-types (~> 2.6, < 2.99)
122
122
  msgpack (~> 0.5)
123
123
  prawn (= 0.8.4)
124
124
  rdoc (~> 3.9)
125
125
  rspec (~> 2.13)
126
126
  sdl4r (~> 0.9)
127
- unicorn-cuba-base (~> 1.2.2)
127
+ unicorn-cuba-base (~> 1.6)
data/README.md CHANGED
@@ -1,22 +1,28 @@
1
1
  # HTTP Image Store
2
2
 
3
- HTTP API server for image thumbnailing and storage.
3
+ Configurable S3 or file system image storage and processing HTTP API server.
4
4
  It is using [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) as image processing backend.
5
5
 
6
6
  ## Features
7
7
 
8
8
  * fully configurable image processing and storage pipeline with custom API configuration capabilities
9
- * thumbnailing of sourced or input image into one or more thumbnails
9
+ * thumbnailing and editing (rotate, crop, blur, etc.) of input or sourced image into one or more thumbnails
10
10
  * sourcing and storage of images on file system
11
11
  * sourcing and storage of images on [Amazon S3](http://aws.amazon.com/s3/)
12
12
  * image output with Cache-Control header
13
13
  * S3 public or private and http:// or https:// URL list output for stored images
14
14
  * S3 read-through and write-through object cache
15
- * storage under custom paths including image hash, content determined extension or used URL path
15
+ * storage under custom paths including image hash, content determined extension or used URI path
16
+ * data URI encoding of image body (for HTML inlining)
17
+ * HMAC based URI authentication
16
18
  * based on [Unicorn HTTP server](http://unicorn.bogomips.org) with UNIX socket communication support
17
19
 
18
20
  ## Changelog
19
21
 
22
+ ### 1.9.0
23
+ * added support for thumbnail edits
24
+ * `validate_uri_hmac` and `validate_header_hmac` support
25
+
20
26
  ### 1.8.0
21
27
  * `output_store_url` support additional arguments: `scheme`, `port` and `host`
22
28
  * `output_store_uri` support added
@@ -82,25 +88,24 @@ Configuration consists of:
82
88
  * S3 client configuration (optional)
83
89
  * storage path definitions
84
90
  * API endpoint definitions
91
+ * request validation
85
92
  * image sourcing operations
86
- * image storage operation
87
- * output operations
93
+ * image storage operations
94
+ * output setup
88
95
 
89
96
  ### Top level configuration elements
90
97
 
91
98
  #### thumbnailer
92
99
 
93
- Configures [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) client. It will be used to perform image processing operations.
100
+ Configures [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) client. It will be used to perform image processing operations with `thumbnail` and `identify` statements.
94
101
 
95
102
  Options:
96
- * `url` - URL of [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) service
97
-
98
- If omitted [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) service located at `http://localhost:3100` will be used.
103
+ * `url` - URL of [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) service; default: `http://localhost:3100`
99
104
 
100
105
  Example:
101
106
 
102
107
  ```sdl
103
- thumbnailer url="http://2.2.2.2:1000"
108
+ thumbnailer url="http://10.2.2.2:3100"
104
109
  ```
105
110
 
106
111
  #### s3
@@ -121,7 +126,7 @@ s3 key="AIAITCKMELYWQZPJP7HQ" secret="V37lCu0F48Tv9s7QVqIT/sLf/wwqhNSB4B0Em7Ei"
121
126
 
122
127
  #### path
123
128
 
124
- This directive is used to define storage and retrieval paths that will be used when storing and sourcing file on file system or S3 service.
129
+ This directive is used to define storage and retrieval paths that will be used when storing and sourcing file on file system or S3 service. They may also be used for generating output paths or URIs.
125
130
  You can declare one path per statement or use `{}` brackets syntax to define more than one with single statement - they are semantically equal.
126
131
 
127
132
  Arguments:
@@ -169,12 +174,12 @@ path {
169
174
  }
170
175
  ```
171
176
 
172
- #### API endpoint
177
+ #### HTTP API endpoint
173
178
 
174
179
  This group of statements allows to configure single API endpoint.
175
- Each endpoint can have one or more operation defined that will be performed on request matching that endpoint.
180
+ Each endpoint can have one or more operation defined that will be performed on HTTP request matching that endpoint.
176
181
 
177
- Endpoints will be evaluated in order of definition until one is matched.
182
+ Endpoints will be evaluated in order of definition until one is matched or **404 Not Found** is returned.
178
183
 
179
184
  Statement should start with one of the following HTTP verbs in lowercase: `get`, `post`, `put`, `delete`, followed by list of URI segment matchers:
180
185
 
@@ -215,7 +220,72 @@ In this example first endpoint will be matched for **GET** request with URI like
215
220
  Second endpoint will be matched only for **PUT** requests with URIs beginning with `/thumbnail/v1/small` and `/thumbnail/v1/large`.
216
221
  Third endpoint will match any **POST** request.
217
222
 
218
- ### API endpoint image sourcing operations
223
+ ### API endpoint validator operations
224
+
225
+ First any defined validators are executed against request to see if we should accept the request or reject it.
226
+
227
+ #### validate_uri_hmac
228
+
229
+ This statement sets up HMAC based URI authentication.
230
+ If HMAC provided with the request does not have the expected value the server will return **403 Forbidden** response.
231
+
232
+ Arguments:
233
+
234
+ 1. query string key for HMAC value - query string parameter key that contains hex encoded HMAC value to be validated against
235
+
236
+ Options:
237
+
238
+ * `secret` - shared secret used to generate HMAC
239
+ * `digest` - digest used for HMAC; see OpenSSL digests for valid values; default: sha1 (for HMAC-SHA1 scheme)
240
+ * `exclude` - comma separated list of query string parameter keys that will be excluded form HMAC computation
241
+ * `remove` - comma separated list of query string parameter keys that will be removed from request for further processing
242
+
243
+ `exclude` is useful when your URI contains extra query string parameters not related to this API that would otherwise brake HMAC computation.
244
+ `remove` can be used to remove all extra (apart form the HMAC parameter itself) HMAC related query string parameters like date or nonce so they don't interact with further statements.
245
+ Adding additional `nonce` or `date` query string parameter can help with HMAC security by 'randomizing' it's value for same URIs - this won't play well with caching though.
246
+
247
+ Example:
248
+
249
+ ```sdl
250
+ get "small" {
251
+ validate_uri_hmac "hmac" secret="key"
252
+ }
253
+ ```
254
+
255
+ In this example request URI `/small?hmac=a49182838f1b0b306614cea1d0fbcdab980717f7` will be valid.
256
+ The actual HMAC is computed from `/small` URI and secret `key` using HMAC-SHA1 scheme.
257
+ Note that `hmac` query string parameter will be removed from the request and won't be accessible by further statements.
258
+
259
+ #### validate_header_hmac
260
+
261
+ This statement is identical in function as `validate_uri_hmac` but takes value for URI from given request header instead.
262
+ This is useful when HTTP Image Store is behind proxy that rewrites URIs. This would normally brake HMAC computation but if it can store the original URI in a header this can be used instead for HMAC computation.
263
+
264
+ Arguments:
265
+
266
+ 1. header name - name of request header that will contain original URI value that will be used for HMAC computation instead of the actual request URI
267
+ 2. query string key for HMAC value - query string parameter key of the actual request URI that contains hex encoded HMAC value to be validated against
268
+
269
+ Options:
270
+
271
+ * `secret` - shared secret used to generate HMAC
272
+ * `digest` - digest used for HMAC; see OpenSSL digests for valid values; default: sha1 (for HMAC-SHA1 scheme)
273
+ * `exclude` - comma separated list of query string parameter keys that will be excluded form HMAC computation
274
+ * `remove` - comma separated list of query string parameter keys that will be removed from request for further processing
275
+
276
+ Example:
277
+
278
+ ```sdl
279
+ get "small" {
280
+ validate_header_hmac "X-ORIGINAL-URI" "hmac" secret="key"
281
+ }
282
+ ```
283
+
284
+ In this example request URI `/my-rewritten-uri?hmac=a49182838f1b0b306614cea1d0fbcdab980717f7` will be valid if request comes with `X-ORIGINAL-URI` header of value `/small`.
285
+ Note that the actual request URI needs only to contain valid `hamc` query string parameter while the value of header needs only the URI necessary for validation - it is OK if it contains the `hmac` query string parameter since it will be removed before computation.
286
+ `remove` will operate on request as normal. `exclude` will operate on the value of the header for the computation to be valid.
287
+
288
+ ## API endpoint image sourcing operations
219
289
 
220
290
  Sourcing will load images into memory for further processing.
221
291
  Each image is stored under predefined or user defined name.
@@ -260,7 +330,7 @@ Options:
260
330
 
261
331
  * `bucket` - name of bucket to source image from
262
332
  * `path` - name of predefined path that will be used to generate key to object to source
263
- * `prefix` - prefix object key with given prefix value; this does not affect format of output URL; prefix will not be included in source path output; default: ``
333
+ * `prefix` - prefix object key with given prefix value; this does not affect format of output URL; prefix will not be included in source path output; default: empty
264
334
  * `cache-root` - path to directory where S3 objects and meta-data will be cached when sourced from S3; read-through mode; if required information was found in cache object no S3 requests will be made; same directory can be used with different buckets since cache key consists of S3 bucket name and object key
265
335
 
266
336
  Example:
@@ -323,6 +393,7 @@ Options:
323
393
  * `height` - requested thumbnail height in pixels
324
394
  * `format` - format in which the resulting image will be encoded; all backend supported formats can be specified like `jpeg` or `png`; default: `jpeg`
325
395
  * `options` - list of options in format `key:value[,key:value]*` to be passed to thumbnailer; this can be a list of any backend supported options like `background-color` or `quality`
396
+ * `edits` - list of edits in format supported by [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) (`[!<edit name>[,<edit arg>]*[,<edit option>:<edit option value>]*]*`)
326
397
  * backend supported options - options can also be defined as statement options
327
398
 
328
399
  Note that you can use `#{variable}` expansion within all of this options.
@@ -350,6 +421,40 @@ put ":operation" ":width" ":height" ":options" {
350
421
  }
351
422
  ```
352
423
 
424
+ ##### edit
425
+
426
+ `thumbnail` statement supports sub statement `edit` that will apply additional edits to the thumbnail image.
427
+ This edits are applied before `edits` option specified edits.
428
+
429
+ Arguments:
430
+
431
+ 1. edit name - name of [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer) supported edit
432
+ 2. argument 1 - first argument
433
+ 3. argument 2 - second argument
434
+ 4. argument n - etc. depending on how many argument the edit needs
435
+
436
+ Options
437
+
438
+ * any options supported by named edit
439
+
440
+ Example:
441
+
442
+ ```sdl
443
+ post "example" "&:rotate?0" "&:crop_x?0.0" "&:crop_y?0.0" "&:crop_w?1.0" "&:crop_h?1.0" "&:edits?" {
444
+ thumbnail "input" "thumbnail" operation="pad" width=100 height=100 format="jpeg" edits="#{edits}" {
445
+ edit "rotate" "#{rotate}"
446
+ edit "crop" "#{crop_x}" "#{crop_y}" "#{crop_w}" "#{crop_h}"
447
+ }
448
+ output_image "thumbnail"
449
+ }
450
+ ```
451
+
452
+ In this example each thumbnail will be first rotated by `rotate` query string parameter value and cropped by query string provided values `crop_x`, `crop_y`, `crop_w`, `crop_h`.
453
+ If query string parameter `edits` is provided it will be used to do additional edits after rotation and cropping is applied.
454
+
455
+ Example URI can look like this: `/example?rotate=90&crop_x=0.1&crop_y=0.1&crop_w=0.8&crop_h=0.8&edits=pixelate,0.2,0.1,0.6,0.6,size:0.03!rectangle,0.1,0.8,0.8,0.1,color:blue`.
456
+ Posted image will be rotated by 90 degree. Than the result will be cropped by 10% from each sied. Next middle region of the image will be pixelated and then blue rectangle will be drawn at the bottom of it. Finally thumbnail of dimensions 100 by 100 will be generated and provided as JPEG encoded image in response body.
457
+
353
458
  #### identify
354
459
 
355
460
  This statement allows for image mime type, width and height identification based on image content with use of [HTTP Thumbnailer](https://github.com/jpastuszek/httpthumbnailer).
@@ -415,7 +520,7 @@ Options:
415
520
  * `bucket` - name of bucket to store image in
416
521
  * `path` - name of predefined path that will be used to generate key to store object under
417
522
  * `public` - if set to `true` the image will be readable by everybody; this affects fromat of output URL; default: `false`
418
- * `prefix` - prefix storeage key with given prefix value; this does not affect fromat of output URL; prefix will not be included in storage path output; default: ``
523
+ * `prefix` - prefix storeage key with given prefix value; this does not affect fromat of output URL; prefix will not be included in storage path output; default: empty
419
524
  * `cache-root` - path to directory where stored S3 objects and meta-data will be cached for future sourcing with `source_s3`; write-through mode; note that same directory needs to be configured with corresponding `source_s3` statement
420
525
 
421
526
  Example:
@@ -485,9 +590,11 @@ The output will contain the posted image with `Content-Type` header set to `appl
485
590
  #### output_data_uri_image
486
591
 
487
592
  This statement will produce `200 OK` response containing base64 encoded image data within data URI in format:
593
+
488
594
  ```
489
595
  data:<image mime type>;base64,<base64 encoded image data>
490
596
  ```
597
+
491
598
  No tailing new line/line feed is added to the output.
492
599
 
493
600
  This may be used to include images directly in HTML pages or CSS.
@@ -684,6 +791,16 @@ The list is in format `image name[,image name]*`.
684
791
 
685
792
  This option is useful when building API that works on predefined set of image operations and allows to select witch set of operations to perform with list included in the URL.
686
793
 
794
+ #### if-variable-matches
795
+
796
+ It can be used on most operation statements and sub statements (`edit`).
797
+
798
+ The argument can contain name of variable to or be in format `<name of variable>:<expected value>`.
799
+ In first from the statement will be executed if variable of given name exists and is non empty.
800
+ In second form the statement will be executed if variable value equals to expected value.
801
+
802
+ This option is useful for example to selectively execute statements based on query string parameters.
803
+
687
804
  ## Configuration examples
688
805
 
689
806
  ### Flexible API example
@@ -1023,12 +1140,14 @@ If running as root you can use `--user` option to specify user with whose privil
1023
1140
 
1024
1141
  Additionally `httpimagestore` will log requests in [common NCSA format](http://en.wikipedia.org/wiki/Common_Log_Format) to `httpimagestore_access.log` file. Use `--access-log-file` option to change location of access log.
1025
1142
 
1026
- Syslog logging can be enabled with `--syslog-facility` option followed by name of syslog facility to use. When enabled log files are not created and both application logs and access logs are sent to syslog.
1027
- Access logs will gain meta information that will include `type="http-access"` that can be used to filter access log entries out from application log entries.
1143
+ Syslog logging can be enabled with `--syslog-facility` option followed by name of syslog facility to use. When enabled log files are not created and both application logs and access logs are sent to syslog.
1144
+ Access logs will gain meta information that will include `"type":"http-access"` that can be used to filter access log entries out from application log entries.
1028
1145
 
1029
1146
  With `--xid-header` option name of HTTP request header can be specified. Value of this header will be logged in meta information tag `xid` along side all request related log entries.
1030
1147
  Named header will be passed down with requests to HTTP Thumbnailer for grater traceability.
1031
1148
 
1149
+ Using `--perf-stats` switch will enable logging of performance statistics. This log entries will be logged with `"type":"perf-stats"`.
1150
+
1032
1151
  ### Running with nginx
1033
1152
 
1034
1153
  [nginx](http://nginx.org) if configured properly will buffer incoming requests before sending them to the backend and server response before sending them to client.
@@ -1129,6 +1248,10 @@ If all goes well `200 OK` will be returned otherwise:
1129
1248
  * bad thumbnail specification
1130
1249
  * empty body when image data expected
1131
1250
 
1251
+ ### 403
1252
+
1253
+ * request not authentic
1254
+
1132
1255
  ### 404
1133
1256
 
1134
1257
  * no API endpoint found for given URL
@@ -1159,31 +1282,37 @@ It is set up under `/stats` URI. You can also request single stat with `/stats/<
1159
1282
  Example:
1160
1283
 
1161
1284
  ```bash
1162
- $ curl 10.1.1.24:3000/stats
1163
- total_requests: 2
1164
- total_errors: 0
1285
+ $ curl 127.0.0.1:3000/stats
1286
+ workers: 10
1287
+ total_requests: 27032164
1288
+ total_errors: 3785333
1165
1289
  calling: 1
1166
1290
  writing: 0
1167
1291
  total_write_multipart: 0
1168
- total_write: 1
1292
+ total_write: 23246830
1169
1293
  total_write_part: 0
1170
- total_write_error: 0
1294
+ total_write_error: 3785333
1171
1295
  total_write_error_part: 0
1172
- total_thumbnail_requests: 1
1173
- total_thumbnail_requests_bytes: 43308
1174
- total_thumbnail_thumbnails: 3
1175
- total_thumbnail_thumbnails_bytes: 102914
1296
+ total_thumbnail_requests: 16415809
1297
+ total_thumbnail_requests_bytes: 1624475247201
1298
+ total_thumbnail_thumbnails: 16414688
1299
+ total_thumbnail_thumbnails_bytes: 61806698184
1300
+ total_identify_requests: 9
1301
+ total_identify_requests_bytes: 73948
1176
1302
  total_file_store: 0
1177
1303
  total_file_store_bytes: 0
1178
1304
  total_file_source: 0
1179
1305
  total_file_source_bytes: 0
1180
- total_s3_store: 4
1181
- total_s3_store_bytes: 146222
1182
- total_s3_source: 1
1183
- total_s3_source_bytes: 51581
1184
-
1185
- $ curl 10.1.1.24:3000/stats/total_s3_source
1186
- 1
1306
+ total_s3_store: 115337
1307
+ total_s3_store_bytes: 11420368878
1308
+ total_s3_source: 17150098
1309
+ total_s3_source_bytes: 1694190265856
1310
+ total_s3_cache_hits: 17149566
1311
+ total_s3_cache_misses: 1416670
1312
+ total_s3_cache_errors: 0
1313
+
1314
+ $ curl 127.0.0.1:3000/stats/total_thumbnail_thumbnails
1315
+ 16414688
1187
1316
  ```
1188
1317
 
1189
1318
  ## Contributing to HTTP Image Store
@@ -1198,6 +1327,5 @@ $ curl 10.1.1.24:3000/stats/total_s3_source
1198
1327
 
1199
1328
  ## Copyright
1200
1329
 
1201
- Copyright (c) 2013 Jakub Pastuszek. See LICENSE.txt for
1202
- further details.
1330
+ Copyright (c) 2013 - 2015 Jakub Pastuszek. See LICENSE.txt for further details.
1203
1331