Skip to content

Commit 7600658

Browse files
committed
http response untouched
1 parent 514fbc4 commit 7600658

File tree

5 files changed

+89
-55
lines changed

5 files changed

+89
-55
lines changed

pom.xml

Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<url>https://github.com/clean-arch-enablers-project/cae-utils-http-client/blob/main/README.md</url>
99
<groupId>com.clean-arch-enablers</groupId>
1010
<artifactId>http-client</artifactId>
11-
<version>0.0.2</version>
11+
<version>1.1.0</version>
1212
<packaging>jar</packaging>
1313
<licenses>
1414
<license>
@@ -63,58 +63,65 @@
6363
<scope>test</scope>
6464
</dependency>
6565
</dependencies>
66-
<build>
67-
<plugins>
68-
<plugin>
69-
<groupId>org.sonatype.central</groupId>
70-
<artifactId>central-publishing-maven-plugin</artifactId>
71-
<version>0.4.0</version>
72-
<extensions>true</extensions>
73-
<configuration>
74-
<publishingServerId>central</publishingServerId>
75-
<tokenAuth>true</tokenAuth>
76-
</configuration>
77-
</plugin>
78-
<plugin>
79-
<groupId>org.apache.maven.plugins</groupId>
80-
<artifactId>maven-javadoc-plugin</artifactId>
81-
<version>3.3.0</version>
82-
<executions>
83-
<execution>
84-
<id>attach-javadocs</id>
85-
<goals>
86-
<goal>jar</goal>
87-
</goals>
88-
</execution>
89-
</executions>
90-
</plugin>
91-
<plugin>
92-
<groupId>org.apache.maven.plugins</groupId>
93-
<artifactId>maven-source-plugin</artifactId>
94-
<version>3.2.1</version>
95-
<executions>
96-
<execution>
97-
<id>attach-sources</id>
98-
<goals>
99-
<goal>jar</goal>
100-
</goals>
101-
</execution>
102-
</executions>
103-
</plugin>
104-
<plugin>
105-
<groupId>org.apache.maven.plugins</groupId>
106-
<artifactId>maven-gpg-plugin</artifactId>
107-
<version>1.6</version>
108-
<executions>
109-
<execution>
110-
<id>sign-artifacts</id>
111-
<phase>deploy</phase>
112-
<goals>
113-
<goal>sign</goal>
114-
</goals>
115-
</execution>
116-
</executions>
117-
</plugin>
118-
</plugins>
119-
</build>
66+
67+
<profiles>
68+
<profile>
69+
<id>deployment</id>
70+
<build>
71+
<plugins>
72+
<plugin>
73+
<groupId>org.sonatype.central</groupId>
74+
<artifactId>central-publishing-maven-plugin</artifactId>
75+
<version>0.4.0</version>
76+
<extensions>true</extensions>
77+
<configuration>
78+
<publishingServerId>central</publishingServerId>
79+
<tokenAuth>true</tokenAuth>
80+
</configuration>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-javadoc-plugin</artifactId>
85+
<version>3.3.0</version>
86+
<executions>
87+
<execution>
88+
<id>attach-javadocs</id>
89+
<goals>
90+
<goal>jar</goal>
91+
</goals>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-source-plugin</artifactId>
98+
<version>3.2.1</version>
99+
<executions>
100+
<execution>
101+
<id>attach-sources</id>
102+
<goals>
103+
<goal>jar</goal>
104+
</goals>
105+
</execution>
106+
</executions>
107+
</plugin>
108+
<plugin>
109+
<groupId>org.apache.maven.plugins</groupId>
110+
<artifactId>maven-gpg-plugin</artifactId>
111+
<version>1.6</version>
112+
<executions>
113+
<execution>
114+
<id>sign-artifacts</id>
115+
<phase>verify</phase>
116+
<goals>
117+
<goal>sign</goal>
118+
</goals>
119+
</execution>
120+
</executions>
121+
</plugin>
122+
</plugins>
123+
</build>
124+
</profile>
125+
</profiles>
126+
120127
</project>

src/main/java/com/cae/http_client/HttpRequestModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
public interface HttpRequestModel {
66

7+
HttpResponse sendRequest();
8+
79
<T> T sendRequestReturning(Class<T> typeOfExpectedResponseBody);
810

911
<T> T sendRequestReturning(TypeReference<T> typeReference);

src/main/java/com/cae/http_client/HttpResponse.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.fasterxml.jackson.core.type.TypeReference;
44

5+
import java.util.List;
6+
import java.util.Map;
57
import java.util.function.Consumer;
68

79
public interface HttpResponse{
@@ -45,4 +47,9 @@ public interface HttpResponse{
4547
* @param checkOnResponse the action to be executed in case of needing handling
4648
*/
4749
void ifNeedsHandling(Consumer<HttpResponse> checkOnResponse);
50+
51+
/**
52+
* @return the response headers
53+
*/
54+
Map<String, List<String>> getHeaders();
4855
}

src/main/java/com/cae/http_client/implementations/HttpRequestModelImplementation.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cae.http_client.implementations;
22

33
import com.cae.http_client.HttpRequestMethod;
4+
import com.cae.http_client.HttpResponse;
45
import com.fasterxml.jackson.core.type.TypeReference;
56
import lombok.AccessLevel;
67
import lombok.NoArgsConstructor;
@@ -25,6 +26,11 @@ public static AbstractHttpRequestModel of(String uri, HttpRequestMethod method,
2526
return httpRequest;
2627
}
2728

29+
@Override
30+
public HttpResponse sendRequest() {
31+
return HttpRequestExecutionManager.of(this).run();
32+
}
33+
2834
@Override
2935
public <T> T sendRequestReturning(Class<T> typeOfExpectedResponseBody) {
3036
return HttpRequestExecutionManager.of(this).run().getBodyAs(typeOfExpectedResponseBody);

src/main/java/com/cae/http_client/implementations/HttpResponseImplementation.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
import com.fasterxml.jackson.core.JsonProcessingException;
77
import com.fasterxml.jackson.core.type.TypeReference;
88

9+
import java.net.http.HttpHeaders;
10+
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
13+
import java.util.Optional;
914
import java.util.function.Consumer;
1015

1116
public class HttpResponseImplementation extends AbstractHttpResponse{
@@ -53,6 +58,13 @@ public void ifNeedsHandling(Consumer<HttpResponse> checkOnResponse) {
5358
checkOnResponse.accept(this);
5459
}
5560

61+
@Override
62+
public Map<String, List<String>> getHeaders() {
63+
return Optional.ofNullable(this.unwrappedHttpResponse.headers())
64+
.map(HttpHeaders::map)
65+
.orElse(new HashMap<>());
66+
}
67+
5668
private boolean isNot2xx() {
5769
var statusString = this.getStatusCode().toString();
5870
return (statusString.charAt(0) != '2');

0 commit comments

Comments
 (0)