Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

set Content-Length header in mapApiGatewayEventToHttpRequest #147

Closed
wants to merge 5 commits into from

Commits on May 30, 2018

  1. set Content-Length header

    - without content-length specified, it seems the body of DELETE requests get ignored
    - per RFC 2616, section 4.3: The presence of a message-body in a request is signaled by the inclusion of a Content-Length or
    Transfer-Encoding header field in the request's message-headers. A message-body MUST NOT be included in a request if
    the specification of the request method (section 5.1.1) does not allow sending an entity-body in requests. A server SHOULD read and forward a message-body on any request; if the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request.
      - in other words, whether or not it is recommended to have a body in a DELETE request, if the content-length header (or the transfer-encoding header) is set, the message body should be forwarded
    - concerns:
      - I'm not sure whether it is necessary to perform more type checking on `event.body`. for instance, if it is an object, it should be passed through a call to `JSON.stringify` before getting the byte length
      - the header should probably be set only if not already specified
    
    This commit is one possible solution to CodeGenieApp#106
    HotelCalifornia committed May 30, 2018
    Configuration menu
    Copy the full SHA
    5d8c486 View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2018

  1. only specify content-length in certain cases

    will now only set the content-length header if the request has a body and the header is not already set
    HotelCalifornia committed Jun 19, 2018
    Configuration menu
    Copy the full SHA
    1ef34b8 View commit details
    Browse the repository at this point in the history

Commits on Jun 21, 2018

  1. update tests

    - fix failing test cases
    - add comment about motivation for change in index.js
    HotelCalifornia committed Jun 21, 2018
    Configuration menu
    Copy the full SHA
    9745be8 View commit details
    Browse the repository at this point in the history
  2. forcibly inject Content-Length into event.headers

    - only if body is present and there are no headers
    - seems hacky, but ensures that the `x-apigateway-event` header is set
    properly(?) later (i.e. including the content-length field)
    HotelCalifornia committed Jun 21, 2018
    Configuration menu
    Copy the full SHA
    462bfdf View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c86713d View commit details
    Browse the repository at this point in the history