Skip to content

fix issue #220, using treemap #234

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -26,7 +27,7 @@ public class APIGatewayCustomAuthorizerEvent {
private String resource;
private String path;
private String httpMethod;
private Map<String, String> headers;
private HttpHeaders<String> headers;
private Map<String, String> queryStringParameters;
private Map<String, String> pathParameters;
private Map<String, String> stageVariables;
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* Class that represents an APIGatewayProxyRequestEvent
@@ -17,9 +18,9 @@ public class APIGatewayProxyRequestEvent implements Serializable, Cloneable {

private String httpMethod;

private Map<String, String> headers;
private HttpHeaders<String> headers;

private Map<String, List<String>> multiValueHeaders;
private HttpHeaders<List<String>> multiValueHeaders;

private Map<String, String> queryStringParameters;

@@ -67,7 +68,8 @@ public static class ProxyRequestContext implements Serializable, Cloneable {
/**
* default constructor
*/
public ProxyRequestContext() {}
public ProxyRequestContext() {
}

/**
* @return account id that owns Lambda function
@@ -101,7 +103,7 @@ public void setAuthorizer(final Map<String, Object> authorizer) {
}

/**
* @return API Gateway stage name
* @return API Gateway stage name
*/
public String getStage() {
return stage;
@@ -286,14 +288,14 @@ public ProxyRequestContext withPath(String path) {

/**
* @return The name of the operation being performed
* */
*/
public String getOperationName() {
return operationName;
}

/**
* @param operationName The name of the operation being performed
* */
*/
public void setOperationName(String operationName) {
this.operationName = operationName;
}
@@ -307,7 +309,6 @@ public ProxyRequestContext withOperationName(String operationName) {
* Returns a string representation of this object; useful for testing and debugging.
*
* @return A string representation of this object.
*
* @see Object#toString()
*/
@Override
@@ -412,7 +413,7 @@ public int hashCode() {
hashCode = prime * hashCode + ((getApiId() == null) ? 0 : getApiId().hashCode());
hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode());
hashCode = prime * hashCode + ((getAuthorizer() == null) ? 0 : getAuthorizer().hashCode());
hashCode = prime * hashCode + ((getOperationName() == null) ? 0: getOperationName().hashCode());
hashCode = prime * hashCode + ((getOperationName() == null) ? 0 : getOperationName().hashCode());
return hashCode;
}

@@ -457,7 +458,8 @@ public static class RequestIdentity implements Serializable, Cloneable {
/**
* default constructor
*/
public RequestIdentity() {}
public RequestIdentity() {
}

/**
* @return The Cognito identity pool id.
@@ -739,7 +741,6 @@ public RequestIdentity withAccessKey(String accessKey) {
* Returns a string representation of this object; useful for testing and debugging.
*
* @return A string representation of this object.
*
* @see Object#toString()
*/
@Override
@@ -869,7 +870,8 @@ public RequestIdentity clone() {
/**
* default constructor
*/
public APIGatewayProxyRequestEvent() {}
public APIGatewayProxyRequestEvent() {
}

/**
* @return The resource path defined in API Gateway
@@ -951,7 +953,15 @@ public Map<String, String> getHeaders() {
* @param headers The headers sent with the request
*/
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
if (headers == null || headers.isEmpty()) {
this.headers = null;
return;
}

if (this.headers == null) {
this.headers = new HttpHeaders<>();
}
this.headers.putAll(headers);
Comment on lines +956 to +964
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change for consumers using setHeaders and expecting it to override all previous values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, we need to remove if (this.headers == null)

}

/**
@@ -974,7 +984,15 @@ public Map<String, List<String>> getMultiValueHeaders() {
* @param multiValueHeaders The multi value headers sent with the request
*/
public void setMultiValueHeaders(Map<String, List<String>> multiValueHeaders) {
this.multiValueHeaders = multiValueHeaders;
if (multiValueHeaders == null || multiValueHeaders.isEmpty()) {
this.multiValueHeaders = null;
return;
}

if (this.multiValueHeaders == null) {
this.multiValueHeaders = new HttpHeaders<>();
}
this.multiValueHeaders.putAll(multiValueHeaders);
}

/**
@@ -1167,7 +1185,6 @@ public APIGatewayProxyRequestEvent withIsBase64Encoded(Boolean isBase64Encoded)
* Returns a string representation of this object; useful for testing and debugging.
*
* @return A string representation of this object.
*
* @see Object#toString()
*/
@Override
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
@@ -13,9 +15,9 @@ public class APIGatewayProxyResponseEvent implements Serializable, Cloneable {

private Integer statusCode;

private Map<String, String> headers;
private HttpHeaders<String> headers;

private Map<String, List<String>> multiValueHeaders;
private HttpHeaders<List<String>> multiValueHeaders;

private String body;

@@ -60,7 +62,15 @@ public Map<String, String> getHeaders() {
* @param headers The Http headers return in the response
*/
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
if (headers == null || headers.isEmpty()) {
this.headers = null;
return;
}

if (this.headers == null) {
this.headers = new HttpHeaders<>();
}
this.headers.putAll(headers);
}

/**
@@ -83,7 +93,15 @@ public Map<String, List<String>> getMultiValueHeaders() {
* @param multiValueHeaders the Http multi value headers to return in the response
*/
public void setMultiValueHeaders(Map<String, List<String>> multiValueHeaders) {
this.multiValueHeaders = multiValueHeaders;
if (multiValueHeaders == null || multiValueHeaders.isEmpty()) {
this.multiValueHeaders = null;
return;
}

if (this.multiValueHeaders == null) {
this.multiValueHeaders = new HttpHeaders<>();
}
this.multiValueHeaders.putAll(multiValueHeaders);
}

/**
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -31,7 +32,7 @@ public class APIGatewayV2CustomAuthorizerEvent {
private String rawPath;
private String rawQueryString;
private List<String> cookies;
private Map<String, String> headers;
private HttpHeaders<String> headers;
private Map<String, String> queryStringParameters;
private RequestContext requestContext;
private Map<String, String> pathParameters;
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@

package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -34,14 +35,26 @@ public class APIGatewayV2HTTPEvent {
private String rawPath;
private String rawQueryString;
private List<String> cookies;
private Map<String, String> headers;
private HttpHeaders<String> headers;
private Map<String, String> queryStringParameters;
private Map<String, String> pathParameters;
private Map<String, String> stageVariables;
private String Body;
private boolean isBase64Encoded;
private RequestContext requestContext;

public void setHeaders(Map<String, String> headers) {
if (headers == null || headers.isEmpty()) {
this.headers = null;
return;
}

if (this.headers == null) {
this.headers = new HttpHeaders<>();
}
this.headers.putAll(headers);
}

@AllArgsConstructor
@Builder(setterPrefix = "with")
@Data
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@

package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -27,9 +28,44 @@
@NoArgsConstructor
public class APIGatewayV2HTTPResponse {
private int statusCode;
private Map<String, String> headers;
private Map<String, List<String>> multiValueHeaders;
private HttpHeaders<String> headers;
private HttpHeaders<List<String>> multiValueHeaders;
private List<String> cookies;
private String body;
private boolean isBase64Encoded;

public static APIGatewayV2HTTPResponseBuilder builder() {
return new APIGatewayV2HTTPResponseBuilder();
}

public static class APIGatewayV2HTTPResponseBuilder {
private HttpHeaders<String> headers;
private HttpHeaders<List<String>> multiValueHeaders;

public APIGatewayV2HTTPResponseBuilder withHeaders(Map<String, String> headers) {
if (headers == null || headers.isEmpty()) {
this.headers = null;
return this;
}

if (this.headers == null) {
this.headers = new HttpHeaders<>();
}
this.headers.putAll(headers);
return this;
}

public APIGatewayV2HTTPResponseBuilder withMultiValueHeaders(Map<String, List<String>> multiValueHeaders) {
if (multiValueHeaders == null || multiValueHeaders.isEmpty()) {
this.multiValueHeaders = null;
return this;
}

if (this.multiValueHeaders == null) {
this.multiValueHeaders = new HttpHeaders<>();
}
this.multiValueHeaders.putAll(multiValueHeaders);
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;

import java.io.Serializable;
import java.util.Map;

@@ -12,8 +14,8 @@ public class APIGatewayV2WebSocketResponse implements Serializable, Cloneable {

private boolean isBase64Encoded = false;
private int statusCode;
private Map<String, String> headers;
private Map<String, String[]> multiValueHeaders;
private HttpHeaders<String> headers;
private HttpHeaders<String[]> multiValueHeaders;
private String body;

public boolean isIsBase64Encoded() {
@@ -37,15 +39,25 @@ public Map<String, String> getHeaders() {
}

public void setHeaders(Map<String, String> headers) {
this.headers = headers;
if (this.headers == null && headers != null && !headers.isEmpty()) {
this.headers = new HttpHeaders<>();
}
if (headers != null && !headers.isEmpty()) {
this.headers.putAll(headers);
}
}

public Map<String, String[]> getMultiValueHeaders() {
return multiValueHeaders;
}

public void setMultiValueHeaders(Map<String, String[]> multiValueHeaders) {
this.multiValueHeaders = multiValueHeaders;
if (this.multiValueHeaders == null && multiValueHeaders != null && !multiValueHeaders.isEmpty()) {
this.multiValueHeaders = new HttpHeaders<>();
}
if (multiValueHeaders != null && !multiValueHeaders.isEmpty()) {
this.multiValueHeaders.putAll(multiValueHeaders);
}
}

public String getBody() {
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.amazonaws.services.lambda.runtime.events;

import com.amazonaws.services.lambda.runtime.events.models.HttpHeaders;
import lombok.Data;
import lombok.NoArgsConstructor;

@@ -40,8 +41,8 @@ public static class RequestContext implements Serializable, Cloneable {
private String path;
private Map<String, String> queryStringParameters;
private Map<String, List<String>> multiValueQueryStringParameters;
private Map<String, String> headers;
private Map<String, List<String>> multiValueHeaders;
private HttpHeaders<String> headers;
private HttpHeaders<List<String>> multiValueHeaders;
private String body;
private boolean isBase64Encoded;

Loading