Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.image Method Fails to Retrieve Specific Document Pages #107

Open
sonofhypnos opened this issue Apr 2, 2024 · 0 comments
Open

client.image Method Fails to Retrieve Specific Document Pages #107

sonofhypnos opened this issue Apr 2, 2024 · 0 comments

Comments

@sonofhypnos
Copy link

sonofhypnos commented Apr 2, 2024

Issue:
Using client.image to fetch pages from EPO's API always returns the first page, regardless of the range parameter provided.

Steps to Reproduce:

  1. Used client.image with range=page to fetch the nth page of a document.
  2. Only the first page was returned in every attempt.

Workaround:
Manually constructing the URL and headers to specify the X-OPS-Range and making a direct request with client._make_request retrieves the correct page.

Expected:
client.image should interpret the range parameter to fetch the specified page number.

Actual:
Always retrieves the first page.

Details:

  • Failing call: client.image("http://ops.epo.org/rest-services/published-data/images/EP/1000000/PA/fullimage", range=page, document_format="application/pdf")
  • Successful workaround:
base_url = "http://ops.epo.org/rest-services/published-data/images"
publication_authority = "EP"
publication_number = "1000000"
publication_kind = "A1"
url = f"{base_url}/{publication_authority}/{publication_number}/{publication_kind}/fullimage"

# Make the request using client._make_request, specifying the Range through parameters and headers
image_response = client._make_request(
    url, 
    data="", 
    params={"Range": page}, 
    extra_headers={"Accept": "application/pdf", "X-OPS-Range": str(page)}, 
    use_get=True
)

(I found the above through trial and error, because I couldn't understand what the data parameter does here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant