Skip to content

Commit 1abeb4a

Browse files
authored
Merge pull request #38 from ChevronETC/http1
update to HTTP 1
2 parents 3084e47 + d3de342 commit 1abeb4a

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "AzStorage"
22
uuid = "c6697862-1611-5eae-9ef8-48803c85c8d6"
3-
version = "1.6.0"
3+
version = "2.0.0"
44

55
[deps]
66
AbstractStorage = "14dbef02-f468-5f15-853e-5ec8dee7b899"
@@ -16,9 +16,9 @@ Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
1616

1717
[compat]
1818
AbstractStorage = "^1.1"
19-
AzSessions = "^1.2"
19+
AzSessions = "2"
2020
AzStorage_jll = "0.4"
21-
HTTP = "0.8, 0.9"
21+
HTTP = "1"
2222
LightXML = "0.9"
2323
julia = "^1.6"
2424

src/AzStorage.jl

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ function isretryable(e::HTTP.StatusError)
139139
false
140140
end
141141
isretryable(e::Base.IOError) = true
142-
isretryable(e::HTTP.IOExtras.IOError) = isretryable(e.e)
142+
isretryable(e::HTTP.Exceptions.ConnectError) = true
143+
isretryable(e::HTTP.Exceptions.HTTPError) = true
144+
isretryable(e::HTTP.Exceptions.RequestError) = true
145+
isretryable(e::HTTP.Exceptions.TimeoutError) = true
143146
isretryable(e::Base.EOFError) = true
144147
isretryable(e::Sockets.DNSError) = Base.uverrorname(e.code) == "EAI_NONAME" ? false : true
145148
isretryable(e) = false
@@ -178,9 +181,10 @@ function Base.mkpath(c::AzContainer)
178181
@retry c.nretry HTTP.request(
179182
"PUT",
180183
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)?restype=container",
181-
Dict(
184+
[
182185
"Authorization" => "Bearer $(token(c.session))",
183-
"x-ms-version" => API_VERSION),
186+
"x-ms-version" => API_VERSION
187+
],
184188
retry = false)
185189
end
186190
nothing
@@ -210,12 +214,13 @@ function writebytes(c::AzContainer, o::AbstractString, data::DenseArray{UInt8};
210214
@retry c.nretry HTTP.request(
211215
"PUT",
212216
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)/$(addprefix(c,o))",
213-
Dict(
217+
[
214218
"Authorization" => "Bearer $(token(c.session))",
215219
"x-ms-version" => API_VERSION,
216220
"Content-Length" => "$(length(data))",
217221
"Content-Type" => contenttype,
218-
"x-ms-blob-type" => "BlockBlob"),
222+
"x-ms-blob-type" => "BlockBlob"
223+
],
219224
data,
220225
retry = false,
221226
verbose = c.verbose)
@@ -233,11 +238,12 @@ function writebytes(c::AzContainer, o::AbstractString, data::DenseArray{UInt8};
233238
@retry c.nretry HTTP.request(
234239
"PUT",
235240
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)/$(addprefix(c,o))?comp=blocklist",
236-
Dict(
241+
[
237242
"x-ms-version" => API_VERSION,
238243
"Authorization" => "Bearer $(token(c.session))",
239244
"Content-Type" => "application/octet-stream",
240-
"Content-Length" => "$(length(blocklist))"),
245+
"Content-Length" => "$(length(blocklist))"
246+
],
241247
blocklist,
242248
retry = false)
243249
nothing
@@ -421,12 +427,13 @@ function readbytes!(c::AzContainer, o::AbstractString, data::DenseArray{UInt8};
421427
@retry c.nretry HTTP.open(
422428
"GET",
423429
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)/$(addprefix(c,o))",
424-
Dict(
430+
[
425431
"Authorization" => "Bearer $(token(c.session))",
426432
"x-ms-version" => API_VERSION,
427-
"Range" => "bytes=$offset-$(offset+length(data)-1)"),
428-
retry = false,
429-
verbose = c.verbose) do io
433+
"Range" => "bytes=$offset-$(offset+length(data)-1)"
434+
];
435+
retry = false,
436+
verbose = c.verbose) do io
430437
read!(io, data)
431438
end
432439
nothing
@@ -608,9 +615,10 @@ function Base.readdir(c::AzContainer; filterlist=true)
608615
r = @retry c.nretry HTTP.request(
609616
"GET",
610617
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)?restype=container&comp=list&marker=$marker",
611-
Dict(
618+
[
612619
"Authorization" => "Bearer $(token(c.session))",
613-
"x-ms-version" => API_VERSION),
620+
"x-ms-version" => API_VERSION
621+
],
614622
retry = false)
615623
xroot = root(parse_string(String(r.body)))
616624
blobs = xroot["Blobs"][1]["Blob"]
@@ -698,9 +706,10 @@ function containers(;storageaccount, session=AzSession(;lazy=true, scope=__OAUTH
698706
r = @retry nretry HTTP.request(
699707
"GET",
700708
"https://$storageaccount.blob.core.windows.net/?comp=list&marker=$marker",
701-
Dict(
709+
[
702710
"Authorization" => "Bearer $(token(session))",
703-
"x-ms-version" => API_VERSION),
711+
"x-ms-version" => API_VERSION
712+
],
704713
retry = false)
705714
xroot = root(parse_string(String(r.body)))
706715
containers = xroot["Containers"][1]["Container"]
@@ -720,9 +729,10 @@ function Base.filesize(c::AzContainer, o::AbstractString)
720729
r = @retry c.nretry HTTP.request(
721730
"HEAD",
722731
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)/$(addprefix(c,o))",
723-
Dict(
732+
[
724733
"Authorization" => "Bearer $(token(c.session))",
725-
"x-ms-version" => API_VERSION),
734+
"x-ms-version" => API_VERSION
735+
],
726736
retry = false)
727737
n = 0
728738
for header in r.headers
@@ -750,9 +760,10 @@ function Base.rm(c::AzContainer, o::AbstractString)
750760
@retry c.nretry HTTP.request(
751761
"DELETE",
752762
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)/$(addprefix(c,o))",
753-
Dict(
763+
[
754764
"Authorization" => "Bearer $(token(c.session))",
755-
"x-ms-version" => API_VERSION),
765+
"x-ms-version" => API_VERSION
766+
],
756767
retry = false)
757768
catch
758769
@warn "error removing $(c.containername)/$(addprefix(c,o))"
@@ -777,9 +788,10 @@ function Base.rm(c::AzContainer)
777788
@retry c.nretry HTTP.request(
778789
"DELETE",
779790
"https://$(c.storageaccount).blob.core.windows.net/$(c.containername)?restype=container",
780-
Dict(
791+
[
781792
"Authorization" => "Bearer $(token(c.session))",
782-
"x-ms-version" => API_VERSION),
793+
"x-ms-version" => API_VERSION
794+
],
783795
retry = false)
784796
end
785797

@@ -812,10 +824,11 @@ function Base.cp(src::AzContainer, dst::AzContainer)
812824
@retry dst.nretry HTTP.request(
813825
"PUT",
814826
"https://$(dst.storageaccount).blob.core.windows.net/$(dst.containername)/$(addprefix(dst,blob))",
815-
Dict(
827+
[
816828
"Authorization" => "Bearer $(token(dst.session))",
817829
"x-ms-version" => API_VERSION,
818-
"x-ms-copy-source" => "https://$(src.storageaccount).blob.core.windows.net/$(src.containername)/$(addprefix(src,blob))"),
830+
"x-ms-copy-source" => "https://$(src.storageaccount).blob.core.windows.net/$(src.containername)/$(addprefix(src,blob))"
831+
],
819832
retry = false)
820833
end
821834
nothing

0 commit comments

Comments
 (0)