72 if (uri_include_all) {
73 if (uri->scheme != NULL) {
74 len += bstr_len(uri->scheme);
78 if ((uri->username != NULL) || (uri->password != NULL)) {
79 if (uri->username != NULL) {
80 len += bstr_len(uri->username);
85 if (uri->password != NULL) {
86 len += bstr_len(uri->password);
92 if (uri->hostname != NULL) {
93 len += bstr_len(uri->hostname);
96 if (uri->port != NULL) {
98 len += bstr_len(uri->port);
102 if (uri->path != NULL) {
103 len += bstr_len(uri->path);
106 if (uri->query != NULL) {
108 len += bstr_len(uri->query);
111 if (uri->fragment != NULL) {
113 len += bstr_len(uri->fragment);
118 bstr *r = bstr_alloc(
len);
123 if (uri_include_all) {
124 if (uri->scheme != NULL) {
125 bstr_add_noex(r, uri->scheme);
126 bstr_add_c_noex(r,
"://");
129 if ((uri->username != NULL) || (uri->password != NULL)) {
130 if (uri->username != NULL) {
131 bstr_add_noex(r, uri->username);
134 bstr_add_c_noex(r,
":");
136 if (uri->password != NULL) {
137 bstr_add_noex(r, uri->password);
140 bstr_add_c_noex(r,
"@");
143 if (uri->hostname != NULL) {
144 bstr_add_noex(r, uri->hostname);
147 if (uri->port != NULL) {
148 bstr_add_c_noex(r,
":");
149 bstr_add_noex(r, uri->port);
153 if (uri->path != NULL) {
154 bstr_add_noex(r, uri->path);
157 if (uri->query != NULL) {
158 bstr *query = bstr_dup(uri->query);
161 htp_urldecode_inplace(tx->cfg, HTP_DECODER_URLENCODED, query, &
flags);
162 bstr_add_c_noex(r,
"?");
163 bstr_add_noex(r, query);
168 if (uri->fragment != NULL) {
169 bstr_add_c_noex(r,
"#");
170 bstr_add_noex(r, uri->fragment);