File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
src/main/java/me/itzg/helpers/http Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 11package me .itzg .helpers .http ;
22
3- import static io .netty .handler .codec .http .HttpHeaderNames .ACCEPT ;
4- import static io .netty .handler .codec .http .HttpHeaderNames .CONTENT_TYPE ;
3+ import static io .netty .handler .codec .http .HttpHeaderNames .*;
54
65import com .fasterxml .jackson .databind .ObjectMapper ;
76import io .netty .handler .codec .http .HttpHeaderNames ;
87import io .netty .handler .codec .http .HttpHeaders ;
98import io .netty .handler .codec .http .HttpStatusClass ;
109import io .netty .handler .codec .http .HttpUtil ;
1110import java .net .URI ;
11+ import java .nio .charset .StandardCharsets ;
1212import java .nio .file .Path ;
1313import java .time .ZoneId ;
1414import java .time .format .DateTimeFormatter ;
15+ import java .util .Base64 ;
1516import java .util .Collections ;
1617import java .util .HashMap ;
1718import java .util .HashSet ;
@@ -241,6 +242,15 @@ protected void applyHeaders(io.netty.handler.codec.http.HttpHeaders headers) {
241242 );
242243 }
243244
245+ final String rawUserInfo = state .uri .getRawUserInfo ();
246+ if (rawUserInfo != null ) {
247+ headers .set (
248+ AUTHORIZATION .toString (),
249+ "Basic " +
250+ Base64 .getEncoder ().encodeToString (rawUserInfo .getBytes (StandardCharsets .UTF_8 ))
251+ );
252+ }
253+
244254 state .requestHeaders .forEach (headers ::set );
245255 }
246256
Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ public Path execute() throws IOException {
6969 public Mono <Path > assemble () {
7070 return useReactiveClient (client ->
7171 client
72+ .headers (this ::applyHeaders )
7273 .followRedirect (true )
7374 .doOnRequest (debugLogRequest (log , "file head fetch" ))
7475 .head ()
@@ -202,6 +203,7 @@ else if (skipUpToDate) {
202203 return alreadyUpToDateMono
203204 .filter (alreadyUpToDate -> !alreadyUpToDate )
204205 .flatMap (notUsed -> client
206+ .headers (this ::applyHeaders )
205207 .headersWhen (headers ->
206208 skipUpToDate ?
207209 fileLastModifiedMono
You can’t perform that action at this time.
0 commit comments