|
15 | 15 | // specific language governing permissions and limitations
|
16 | 16 | // under the License.
|
17 | 17 |
|
18 |
| -use super::error::parse_error; |
19 |
| -use crate::raw::{ |
20 |
| - build_abs_path, new_json_deserialize_error, new_json_serialize_error, new_request_build_error, |
21 |
| - percent_encode_path, AccessorInfo, HttpClient, |
22 |
| -}; |
23 |
| -use crate::*; |
| 18 | +use std::env; |
| 19 | +use std::fmt::{Debug, Formatter}; |
| 20 | +use std::str::FromStr; |
| 21 | +use std::sync::Arc; |
| 22 | + |
24 | 23 | use ::ghac::v1 as ghac_types;
|
25 | 24 | use bytes::{Buf, Bytes};
|
26 | 25 | use http::header::{ACCEPT, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE};
|
27 | 26 | use http::{Request, StatusCode, Uri};
|
28 | 27 | use prost::Message;
|
29 | 28 | use serde::{Deserialize, Serialize};
|
30 |
| -use std::env; |
31 |
| -use std::fmt::{Debug, Formatter}; |
32 |
| -use std::str::FromStr; |
33 |
| -use std::sync::Arc; |
| 29 | + |
| 30 | +use super::error::parse_error; |
| 31 | +use crate::raw::*; |
| 32 | +use crate::*; |
34 | 33 |
|
35 | 34 | /// The base url for cache url.
|
36 | 35 | pub const CACHE_URL_BASE: &str = "_apis/artifactcache";
|
@@ -76,7 +75,6 @@ pub struct GhacCore {
|
76 | 75 | pub version: String,
|
77 | 76 |
|
78 | 77 | pub service_version: GhacVersion,
|
79 |
| - pub http_client: HttpClient, |
80 | 78 | }
|
81 | 79 |
|
82 | 80 | impl Debug for GhacCore {
|
@@ -108,7 +106,7 @@ impl GhacCore {
|
108 | 106 | req = req.header(ACCEPT, CACHE_HEADER_ACCEPT);
|
109 | 107 |
|
110 | 108 | let req = req.body(Buffer::new()).map_err(new_request_build_error)?;
|
111 |
| - let resp = self.http_client.send(req).await?; |
| 109 | + let resp = self.info.http_client().send(req).await?; |
112 | 110 | let location = if resp.status() == StatusCode::OK {
|
113 | 111 | let slc = resp.into_body();
|
114 | 112 | let query_resp: GhacQueryResponse = serde_json::from_reader(slc.reader())
|
@@ -141,7 +139,7 @@ impl GhacCore {
|
141 | 139 | .header(CONTENT_LENGTH, body.len())
|
142 | 140 | .body(body)
|
143 | 141 | .map_err(new_request_build_error)?;
|
144 |
| - let resp = self.http_client.send(req).await?; |
| 142 | + let resp = self.info.http_client().send(req).await?; |
145 | 143 | let location = if resp.status() == StatusCode::OK {
|
146 | 144 | let slc = resp.into_body();
|
147 | 145 | let query_resp = ghac_types::GetCacheEntryDownloadUrlResponse::decode(slc)
|
@@ -195,7 +193,7 @@ impl GhacCore {
|
195 | 193 | let req = req
|
196 | 194 | .body(Buffer::from(Bytes::from(bs)))
|
197 | 195 | .map_err(new_request_build_error)?;
|
198 |
| - let resp = self.http_client.send(req).await?; |
| 196 | + let resp = self.info.http_client().send(req).await?; |
199 | 197 | let cache_id = if resp.status().is_success() {
|
200 | 198 | let slc = resp.into_body();
|
201 | 199 | let reserve_resp: GhacReserveResponse = serde_json::from_reader(slc.reader())
|
@@ -227,7 +225,7 @@ impl GhacCore {
|
227 | 225 | .header(CONTENT_LENGTH, body.len())
|
228 | 226 | .body(body)
|
229 | 227 | .map_err(new_request_build_error)?;
|
230 |
| - let resp = self.http_client.send(req).await?; |
| 228 | + let resp = self.info.http_client().send(req).await?; |
231 | 229 | let location = if resp.status() == StatusCode::OK {
|
232 | 230 | let (parts, slc) = resp.into_parts();
|
233 | 231 | let query_resp = ghac_types::CreateCacheEntryResponse::decode(slc)
|
@@ -263,7 +261,7 @@ impl GhacCore {
|
263 | 261 | .header(CONTENT_LENGTH, bs.len())
|
264 | 262 | .body(Buffer::from(bs))
|
265 | 263 | .map_err(new_request_build_error)?;
|
266 |
| - let resp = self.http_client.send(req).await?; |
| 264 | + let resp = self.info.http_client().send(req).await?; |
267 | 265 | if resp.status().is_success() {
|
268 | 266 | Ok(())
|
269 | 267 | } else {
|
@@ -291,7 +289,7 @@ impl GhacCore {
|
291 | 289 | .header(CONTENT_LENGTH, body.len())
|
292 | 290 | .body(body)
|
293 | 291 | .map_err(new_request_build_error)?;
|
294 |
| - let resp = self.http_client.send(req).await?; |
| 292 | + let resp = self.info.http_client().send(req).await?; |
295 | 293 | if resp.status() != StatusCode::OK {
|
296 | 294 | return Err(parse_error(resp));
|
297 | 295 | };
|
|
0 commit comments