Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c197dc6

Browse filesBrowse files
committed
Revert "Merge pull request hub4j#1083 from bitwiseman/issue/754"
This reverts commit 837526c, reversing changes made to 8b3f50d.
1 parent 196ee25 commit c197dc6
Copy full SHA for c197dc6

File tree

Expand file treeCollapse file tree

104 files changed

+395
-625
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

104 files changed

+395
-625
lines changed

‎src/main/java/org/kohsuke/github/GitHubHttpUrlConnectionClient.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GitHubHttpUrlConnectionClient.java
+24-2Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.IOException;
77
import java.io.InputStream;
8+
import java.lang.reflect.Field;
89
import java.net.HttpURLConnection;
910
import java.net.ProtocolException;
1011
import java.nio.charset.StandardCharsets;
@@ -162,9 +163,30 @@ private static void setRequestMethod(String method, HttpURLConnection connection
162163
connection.setRequestMethod(method);
163164
} catch (ProtocolException e) {
164165
// JDK only allows one of the fixed set of verbs. Try to override that
165-
connection.setRequestProperty("X-HTTP-Method-Override", method);
166-
connection.setRequestMethod("POST");
166+
try {
167+
Field $method = HttpURLConnection.class.getDeclaredField("method");
168+
$method.setAccessible(true);
169+
$method.set(connection, method);
170+
} catch (Exception x) {
171+
throw (IOException) new IOException("Failed to set the custom verb").initCause(x);
172+
}
173+
// sun.net.www.protocol.https.DelegatingHttpsURLConnection delegates to another HttpURLConnection
174+
try {
175+
Field $delegate = connection.getClass().getDeclaredField("delegate");
176+
$delegate.setAccessible(true);
177+
Object delegate = $delegate.get(connection);
178+
if (delegate instanceof HttpURLConnection) {
179+
HttpURLConnection nested = (HttpURLConnection) delegate;
180+
setRequestMethod(method, nested);
181+
}
182+
} catch (NoSuchFieldException x) {
183+
// no problem
184+
} catch (IllegalAccessException x) {
185+
throw (IOException) new IOException("Failed to set the custom verb").initCause(x);
186+
}
167187
}
188+
if (!connection.getRequestMethod().equals(method))
189+
throw new IllegalStateException("Failed to set the request method to " + method);
168190
}
169191

170192
/**

‎src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java

Copy file name to clipboardExpand all lines: src/test/java/org/kohsuke/github/junit/GitHubWireMockRule.java
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ private void recordSnapshot(WireMockServer server, String target, boolean isRawS
159159
if (server != null) {
160160

161161
server.snapshotRecord(recordSpec().forTarget(target)
162-
// "X-HTTP-Method-Override" is used to send http methods not supported by
163-
// HttpURLConnection without using hacky Java reflection techniques
164-
.captureHeader("X-HTTP-Method-Override")
165162
// "If-None-Match" header used for ETag matching for caching connections
166163
.captureHeader("If-None-Match")
167164
// "If-Modified-Since" header used for ETag matching for caching connections

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/notifications_threads_523050578-25.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/notifications_threads_523050578-25.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
"name": "notifications_threads_523050578",
44
"request": {
55
"url": "/notifications/threads/523050578",
6+
"method": "PATCH",
67
"bodyPatterns": [
78
{
89
"equalToJson": "{}",
910
"ignoreArrayOrder": true,
1011
"ignoreExtraElements": true
1112
}
1213
],
13-
"method": "POST",
1414
"headers": {
15-
"X-HTTP-Method-Override": {
16-
"equalTo": "PATCH"
17-
},
1815
"Accept": {
1916
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
2017
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateCommitComment/mappings/repos_kohsuke_sandbox-ant_comments_46267761-7.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateCommitComment/mappings/repos_kohsuke_sandbox-ant_comments_46267761-7.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"name": "repos_kohsuke_sandbox-ant_comments_46267761",
44
"request": {
55
"url": "/repos/kohsuke/sandbox-ant/comments/46267761",
6-
"method": "POST",
6+
"method": "PATCH",
77
"headers": {
8-
"X-HTTP-Method-Override": {
9-
"equalTo": "PATCH"
10-
},
118
"Accept": {
129
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
1310
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateIssue/mappings/repos_hub4j-test-org_github-api-test_issues_1-11.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testCreateIssue/mappings/repos_hub4j-test-org_github-api-test_issues_1-11.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
"name": "repos_hub4j-test-org_github-api-test_issues_1",
44
"request": {
55
"url": "/repos/hub4j-test-org/github-api-test/issues/1",
6+
"method": "PATCH",
67
"bodyPatterns": [
78
{
89
"equalToJson": "{\"state\":\"closed\"}",
910
"ignoreArrayOrder": true,
1011
"ignoreExtraElements": true
1112
}
1213
],
13-
"method": "POST",
1414
"headers": {
15-
"X-HTTP-Method-Override": {
16-
"equalTo": "PATCH"
17-
},
1815
"Accept": {
1916
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
2017
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-3.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-3.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"name": "repos_bitwiseman_github-api-test-rename",
44
"request": {
55
"url": "/repos/bitwiseman/github-api-test-rename",
6-
"method": "POST",
6+
"method": "PATCH",
77
"headers": {
8-
"X-HTTP-Method-Override": {
9-
"equalTo": "PATCH"
10-
},
118
"Accept": {
129
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
1310
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-4.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-4.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"name": "repos_bitwiseman_github-api-test-rename",
44
"request": {
55
"url": "/repos/bitwiseman/github-api-test-rename",
6-
"method": "POST",
6+
"method": "PATCH",
77
"headers": {
8-
"X-HTTP-Method-Override": {
9-
"equalTo": "PATCH"
10-
},
118
"Accept": {
129
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
1310
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-5.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-5.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"name": "repos_bitwiseman_github-api-test-rename",
44
"request": {
55
"url": "/repos/bitwiseman/github-api-test-rename",
6-
"method": "POST",
6+
"method": "PATCH",
77
"headers": {
8-
"X-HTTP-Method-Override": {
9-
"equalTo": "PATCH"
10-
},
118
"Accept": {
129
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
1310
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-6.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-6.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"name": "repos_bitwiseman_github-api-test-rename",
44
"request": {
55
"url": "/repos/bitwiseman/github-api-test-rename",
6-
"method": "POST",
6+
"method": "PATCH",
77
"headers": {
8-
"X-HTTP-Method-Override": {
9-
"equalTo": "PATCH"
10-
},
118
"Accept": {
129
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
1310
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-7.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoCRUD/mappings/repos_bitwiseman_github-api-test-rename-7.json
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"name": "repos_bitwiseman_github-api-test-rename",
44
"request": {
55
"url": "/repos/bitwiseman/github-api-test-rename",
6-
"method": "POST",
6+
"method": "PATCH",
77
"headers": {
8-
"X-HTTP-Method-Override": {
9-
"equalTo": "PATCH"
10-
},
118
"Accept": {
129
"equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
1310
}

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoLabel/__files/repos_hub4j-test-org_test-labels-2.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoLabel/__files/repos_hub4j-test-org_test-labels-2.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"login": "hub4j-test-org",
99
"id": 7544739,
1010
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
11-
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
11+
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
1212
"gravatar_id": "",
1313
"url": "https://api.github.com/users/hub4j-test-org",
1414
"html_url": "https://github.com/hub4j-test-org",
@@ -105,7 +105,7 @@
105105
"login": "hub4j-test-org",
106106
"id": 7544739,
107107
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
108-
"avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4",
108+
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
109109
"gravatar_id": "",
110110
"url": "https://api.github.com/users/hub4j-test-org",
111111
"html_url": "https://github.com/hub4j-test-org",

‎src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoLabel/__files/user-1.json

Copy file name to clipboardExpand all lines: src/test/resources/org/kohsuke/github/AppTest/wiremock/testRepoLabel/__files/user-1.json
+19-8Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"login": "bitwiseman",
33
"id": 1958953,
44
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
5-
"avatar_url": "https://avatars.githubusercontent.com/u/1958953?v=4",
5+
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
66
"gravatar_id": "",
77
"url": "https://api.github.com/users/bitwiseman",
88
"html_url": "https://github.com/bitwiseman",
@@ -23,12 +23,23 @@
2323
"location": "Seattle, WA, USA",
2424
"email": "bitwiseman@gmail.com",
2525
"hireable": null,
26-
"bio": null,
27-
"twitter_username": "bitwiseman",
28-
"public_repos": 206,
29-
"public_gists": 8,
30-
"followers": 181,
31-
"following": 11,
26+
"bio": "https://twitter.com/bitwiseman",
27+
"public_repos": 181,
28+
"public_gists": 7,
29+
"followers": 149,
30+
"following": 9,
3231
"created_at": "2012-07-11T20:38:33Z",
33-
"updated_at": "2021-04-02T21:55:29Z"
32+
"updated_at": "2020-03-26T21:08:45Z",
33+
"private_gists": 8,
34+
"total_private_repos": 10,
35+
"owned_private_repos": 0,
36+
"disk_usage": 33697,
37+
"collaborators": 0,
38+
"two_factor_authentication": true,
39+
"plan": {
40+
"name": "free",
41+
"space": 976562499,
42+
"collaborators": 0,
43+
"private_repos": 10000
44+
}
3445
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "55f5d0e7-2f1f-4a8a-812c-204ea56540f7",
2+
"id": "e24be5d0-73bf-4748-8c79-a68eb5e2becf",
33
"name": "repos_hub4j-test-org_test-labels",
44
"request": {
55
"url": "/repos/hub4j-test-org/test-labels",
@@ -14,33 +14,33 @@
1414
"status": 200,
1515
"bodyFileName": "repos_hub4j-test-org_test-labels-2.json",
1616
"headers": {
17-
"Server": "GitHub.com",
18-
"Date": "Thu, 08 Apr 2021 20:38:59 GMT",
17+
"Date": "Thu, 26 Mar 2020 21:52:19 GMT",
1918
"Content-Type": "application/json; charset=utf-8",
19+
"Server": "GitHub.com",
20+
"Status": "200 OK",
21+
"X-RateLimit-Limit": "5000",
22+
"X-RateLimit-Remaining": "4993",
23+
"X-RateLimit-Reset": "1585263138",
2024
"Cache-Control": "private, max-age=60, s-maxage=60",
2125
"Vary": [
2226
"Accept, Authorization, Cookie, X-GitHub-OTP",
23-
"Accept-Encoding, Accept, X-Requested-With"
27+
"Accept-Encoding, Accept, X-Requested-With, X-GitHub-OpenAPI"
2428
],
25-
"ETag": "W/\"86fbc9276b6690bc16bd74f81c0ce45c1f5fda7db638aaa2c4bb0bcdd63da176\"",
29+
"ETag": "W/\"6b3e989ed9af12ce6cd75038c1664ab5\"",
2630
"Last-Modified": "Sun, 15 Feb 2015 14:49:09 GMT",
27-
"X-OAuth-Scopes": "repo, workflow",
31+
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion",
2832
"X-Accepted-OAuth-Scopes": "repo",
2933
"X-GitHub-Media-Type": "unknown, github.v3",
30-
"X-RateLimit-Limit": "5000",
31-
"X-RateLimit-Remaining": "4937",
32-
"X-RateLimit-Reset": "1617917629",
33-
"X-RateLimit-Used": "63",
3434
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
3535
"X-Frame-Options": "deny",
3636
"X-Content-Type-Options": "nosniff",
37-
"X-XSS-Protection": "0",
37+
"X-XSS-Protection": "1; mode=block",
3838
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
3939
"Content-Security-Policy": "default-src 'none'",
40-
"X-GitHub-Request-Id": "E09C:148F:17AC74:19F151:606F69E3"
40+
"X-GitHub-Request-Id": "E69B:9495:1D1CC:2452B:5E7D2411"
4141
}
4242
},
43-
"uuid": "55f5d0e7-2f1f-4a8a-812c-204ea56540f7",
43+
"uuid": "e24be5d0-73bf-4748-8c79-a68eb5e2becf",
4444
"persistent": true,
4545
"insertionIndex": 2
4646
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "7896038e-2291-4a94-8ce9-ea12923353b2",
2+
"id": "2c942d88-1a5a-4fba-ae09-ada2a5dff83f",
33
"name": "repos_hub4j-test-org_test-labels_labels",
44
"request": {
55
"url": "/repos/hub4j-test-org/test-labels/labels",
@@ -13,41 +13,41 @@
1313
{
1414
"equalToJson": "{\"color\":\"123457\",\"name\":\"test2\",\"description\":\"this is a different test\"}",
1515
"ignoreArrayOrder": true,
16-
"ignoreExtraElements": false
16+
"ignoreExtraElements": true
1717
}
1818
]
1919
},
2020
"response": {
2121
"status": 201,
22-
"body": "{\"id\":2897001309,\"node_id\":\"MDU6TGFiZWwyODk3MDAxMzA5\",\"url\":\"https://api.github.com/repos/hub4j-test-org/test-labels/labels/test2\",\"name\":\"test2\",\"color\":\"123457\",\"default\":false,\"description\":\"this is a different test\"}",
22+
"body": "{\"id\":1937402965,\"node_id\":\"MDU6TGFiZWwxOTM3NDAyOTY1\",\"url\":\"https://api.github.com/repos/hub4j-test-org/test-labels/labels/test2\",\"name\":\"test2\",\"color\":\"123457\",\"default\":false,\"description\":\"this is a different test\"}",
2323
"headers": {
24-
"Server": "GitHub.com",
25-
"Date": "Thu, 08 Apr 2021 20:39:02 GMT",
24+
"Date": "Thu, 26 Mar 2020 21:52:22 GMT",
2625
"Content-Type": "application/json; charset=utf-8",
26+
"Server": "GitHub.com",
27+
"Status": "201 Created",
28+
"X-RateLimit-Limit": "5000",
29+
"X-RateLimit-Remaining": "4980",
30+
"X-RateLimit-Reset": "1585263137",
2731
"Cache-Control": "private, max-age=60, s-maxage=60",
2832
"Vary": [
2933
"Accept, Authorization, Cookie, X-GitHub-OTP",
30-
"Accept-Encoding, Accept, X-Requested-With"
34+
"Accept-Encoding, Accept, X-Requested-With, X-GitHub-OpenAPI"
3135
],
32-
"ETag": "\"6bb2796b20a76d6ab8e7a147bf6b19cf6d0605587e59367c34afe06bb4786f60\"",
33-
"X-OAuth-Scopes": "repo, workflow",
36+
"ETag": "\"648a902d66c2f46f74c7b836969fdfe9\"",
37+
"X-OAuth-Scopes": "admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion",
3438
"X-Accepted-OAuth-Scopes": "",
39+
"Location": "https://api.github.com/repos/hub4j-test-org/test-labels/labels/test2",
3540
"X-GitHub-Media-Type": "unknown, github.v3",
36-
"X-RateLimit-Limit": "5000",
37-
"X-RateLimit-Remaining": "4924",
38-
"X-RateLimit-Reset": "1617917629",
39-
"X-RateLimit-Used": "76",
4041
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
4142
"X-Frame-Options": "deny",
4243
"X-Content-Type-Options": "nosniff",
43-
"X-XSS-Protection": "0",
44+
"X-XSS-Protection": "1; mode=block",
4445
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
4546
"Content-Security-Policy": "default-src 'none'",
46-
"X-GitHub-Request-Id": "E09C:148F:17AD20:19F219:606F69E6",
47-
"Location": "https://api.github.com/repos/hub4j-test-org/test-labels/labels/test2"
47+
"X-GitHub-Request-Id": "E69B:9495:1D214:245B7:5E7D2416"
4848
}
4949
},
50-
"uuid": "7896038e-2291-4a94-8ce9-ea12923353b2",
50+
"uuid": "2c942d88-1a5a-4fba-ae09-ada2a5dff83f",
5151
"persistent": true,
5252
"insertionIndex": 15
5353
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.