CARVIEW |
Select Language
HTTP/2 200
date: Sun, 12 Oct 2025 05:14:58 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"8fabe1bbafbd01205a5c5d6790b1ac6f"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com github.githubassets.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com marketplace-screenshots.githubusercontent.com/ copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=dXinRp02YyaYIaBI%2BTA%2FEZ3CUzZ1AUbFiY4tHUVsMNuaqc4hsSWrDtl9VXwmYKx4N2OLPZhxPKrr9gIvJf4QcmVikTLVWaj5wXGh89RhxtQg%2BQQ5vdYMCpOvSYGLiKqQnPl6xRy9aJHj%2BYwG%2FXkwBB7zbjhBIp1BXq6uAv%2ByCGfa%2BIYyikHh33azkEK4wScihV3mbNvKbryM3UG7SeF7sCZJG4EB3%2B5YwdmwGjkIWT1Ug0oxAZ8R77qwRwjaYg4pTIAGWP91ERqzodtVtr8ooQ%3D%3D--qqxFA8QQte1my6fx--71CMt9CnFmRM4pf6al43wQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1314314652.1760246098; Path=/; Domain=github.com; Expires=Mon, 12 Oct 2026 05:14:58 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 12 Oct 2026 05:14:58 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: A486:2C8153:C27EDD:105C783:68EB3952
Version of the attoparsec http-header example for pre-release version of Combine. · GitHub
Show Gist options
Save m4rw3r/fcf84cb3d3df1d555177 to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
Last active
August 29, 2015 14:27
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save m4rw3r/fcf84cb3d3df1d555177 to your computer and use it in GitHub Desktop.
Version of the attoparsec http-header example for pre-release version of Combine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate combine; | |
use combine::*; | |
use combine::combinator::{take_while1, range}; | |
use combine::primitives::Error; | |
use std::fs::File; | |
use std::env; | |
#[derive(Debug)] | |
struct Request<'a> { | |
method: &'a [u8], | |
uri: &'a [u8], | |
version: &'a [u8], | |
} | |
#[derive(Debug)] | |
struct Header<'a> { | |
name: &'a [u8], | |
value: Vec<&'a [u8]>, | |
} | |
fn is_token(c: u8) -> bool { | |
c < 128 && c > 31 && b"()<>@,;:\\\"/[]?={} \t".iter().position(|&i| i == c).is_none() | |
} | |
fn is_horizontal_space(c: u8) -> bool { c == b' ' || c == b'\t' } | |
fn is_space(c: u8) -> bool { c == b' ' } | |
fn is_not_space(c: u8) -> bool { c != b' ' } | |
fn is_http_version(c: u8) -> bool { c >= b'0' && c <= b'9' || c == b'.' } | |
fn main() { | |
let mut contents: Vec<u8> = Vec::new(); | |
{ | |
use std::io::Read; | |
let mut file = File::open(env::args().nth(1).expect("File to read")).ok().expect("Failed to open file"); | |
let _ = file.read_to_end(&mut contents).unwrap(); | |
} | |
// Making a closure, because parser instances cannot be reused | |
let end_of_line = || (satisfy(|&c| c == b'\r').skip(satisfy(|&c| c == b'\n'))).or(satisfy(|&c| c == b'\n')); | |
let mut http_version = range(&b"HTTP/"[..]) | |
.with(take_while1(|&&c| is_http_version(c))); | |
let request_line = parser(|input| ( | |
// dereferencing pointers before checking if it is a token | |
take_while1(|&&c| is_token(c)), | |
take_while1(|&&c| is_space(c)), | |
take_while1(|&&c| is_not_space(c)), | |
take_while1(|&&c| is_space(c)), | |
&mut http_version, | |
).map(|(method, _, uri, _, version)| Request { | |
method: method, | |
uri: uri, | |
version: version, | |
}) | |
.parse_lazy(input) | |
); | |
let message_header = parser(|input| { | |
let message_header_line = ( | |
take_while1(|&&c| is_horizontal_space(c)), | |
take_while1(|&&c| c != b'\r' && c != b'\n'), | |
end_of_line() | |
).map(|(_, line, _)| line); | |
( | |
take_while1(|&&c| is_token(c)), | |
satisfy(|&c| c == b':'), | |
many1(message_header_line) | |
).map(|(name, _, value)| Header { | |
name: name, | |
value: value, | |
}) | |
.parse_lazy(input) | |
}); | |
let mut request = ( | |
request_line, | |
end_of_line(), | |
many(message_header), | |
end_of_line() | |
).map(|(request, _, headers, _)| (request, headers)); | |
let mut i = 0; | |
let mut buf = &contents[..]; | |
loop { | |
// Needed for inferrence for many(message_header) | |
let r: Result<((Request, Vec<Header>), _), _> = request.parse(buf); | |
match r { | |
Ok(((_, _), b)) => { | |
i = i + 1; | |
buf = b | |
}, | |
Err(e) => { | |
if e.errors[0] == Error::end_of_input() { | |
return | |
} | |
panic!("{:?}", e); | |
} | |
} | |
if buf.is_empty() { | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.