()
| 1138 | } |
| 1139 | |
| 1140 | private headersCompleted(): Node { |
| 1141 | const p = this.llparse; |
| 1142 | const callback = this.callback; |
| 1143 | const n = (name: string): Match => this.node<Match>(name); |
| 1144 | |
| 1145 | // Set `upgrade` if needed |
| 1146 | const beforeHeadersComplete = p.invoke(callback.beforeHeadersComplete); |
| 1147 | |
| 1148 | /* Here we call the headers_complete callback. This is somewhat |
| 1149 | * different than other callbacks because if the user returns 1, we |
| 1150 | * will interpret that as saying that this message has no body. This |
| 1151 | * is needed for the annoying case of receiving a response to a HEAD |
| 1152 | * request. |
| 1153 | * |
| 1154 | * We'd like to use CALLBACK_NOTIFY_NOADVANCE() here but we cannot, so |
| 1155 | * we have to simulate it by handling a change in errno below. |
| 1156 | */ |
| 1157 | const onHeadersComplete = p.invoke(callback.onHeadersComplete, { |
| 1158 | 0: n('headers_done'), |
| 1159 | 1: this.setFlag(FLAGS.SKIPBODY, 'headers_done'), |
| 1160 | 2: this.update('upgrade', 1, |
| 1161 | this.setFlag(FLAGS.SKIPBODY, 'headers_done')), |
| 1162 | [ERROR.PAUSED]: this.pause('Paused by on_headers_complete', |
| 1163 | 'headers_done'), |
| 1164 | }, p.error(ERROR.CB_HEADERS_COMPLETE, 'User callback error')); |
| 1165 | |
| 1166 | beforeHeadersComplete.otherwise(onHeadersComplete); |
| 1167 | |
| 1168 | return beforeHeadersComplete; |
| 1169 | } |
| 1170 | |
| 1171 | private node<T extends Node>(name: string | T): T { |
| 1172 | if (name instanceof Node) { |
no test coverage detected