Revision d29f0371 snf-astakos-app/astakos/api/util.py

b/snf-astakos-app/astakos/api/util.py
206 206
        return
207 207
    d[new] = d[old]
208 208
    del(d[old])
209

  
210

  
211
def get_int_parameter(p):
212
    if p is not None:
213
        try:
214
            p = int(p)
215
        except ValueError:
216
            return None
217
        if p < 0:
218
            return None
219
    return p
220

  
221

  
222
def get_content_length(request):
223
    content_length = get_int_parameter(request.META.get('CONTENT_LENGTH'))
224
    if content_length is None:
225
        raise faults.LengthRequired('Missing or invalid Content-Length header')
226
    return content_length

Also available in: Unified diff