FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
git2cpp/src/wasm/response.cpp at main · QuantStack/git2cpp · GitHub
QuantStack
git2cpp
Repository navigation
Code
Issues
6
(6)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
git2cpp
/
src
/
wasm
/
response.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (74 loc) · 2.11 KB
Breadcrumbs
git2cpp
/
src
/
wasm
/
response.cpp
Copy path
File metadata and controls
85 lines (74 loc) · 2.11 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#
ifdef
EMSCRIPTEN
#
include
"
response.hpp
"
#
include
"
../utils/common.hpp
"
#
include
"
libgit2_internals.hpp
"
wasm_http_response::wasm_http_response
()
: m_status(
0
)
, m_read_count(
0
)
, m_total_bytes(
0
)
{
}
void
wasm_http_response::add_header
(
const
std::string& key,
const
std::string& value)
{
m_response_headers.
emplace
(key,
trim
(value));
}
void
wasm_http_response::clear
()
{
m_status =
0
;
m_status_text.
clear
();
m_read_count =
0
;
m_total_bytes =
0
;
m_response_headers.
clear
();
}
std::optional<std::string>
wasm_http_response::get_header
(
const
std::string& key)
const
{
//
Return the first header with the specified key.
//
If we ever have to handle multiple headers with the same key, will need to do something more
//
complicated here.
auto
header = m_response_headers.
find
(key);
if
(header != m_response_headers.
end
())
{
return
header->
second
;
}
return
std::
nullopt
;
}
bool
wasm_http_response::has_header
(
const
std::string& key)
const
{
return
m_response_headers.
find
(key) != m_response_headers.
end
();
}
bool
wasm_http_response::has_header_matches
(
const
std::string& key, std::string_view match)
const
{
auto
range = m_response_headers.
equal_range
(key);
for
(
auto
i = range.
first
; i != range.
second
; ++i)
{
if
(i->
second
== match)
{
return
true
;
}
}
return
false
;
}
bool
wasm_http_response::has_header_starts_with
(
const
std::string& key, std::string_view start)
const
{
auto
range = m_response_headers.
equal_range
(key);
for
(
auto
i = range.
first
; i != range.
second
; ++i)
{
if
(i->
second
.
starts_with
(start))
{
return
true
;
}
}
return
false
;
}
void
wasm_http_response::set_git_error
(std::string_view url)
const
{
std::string extra = m_status_text.
empty
() ?
"
"
:
"
(
"
+ m_status_text +
"
)
"
;
git_error_set
(
GIT_ERROR_HTTP
,
"
unexpected HTTP response %d%s to request %s, see the browser console and/or network tab for more details
"
,
m_status,
extra.
c_str
(),
url.
data
()
);
}
#
endif
//
EMSCRIPTEN
Back
|
FazBrowse Home
|
New Git URL